ash/extensions/khr/
get_physical_device_properties2.rs1use crate::prelude::*;
2use crate::vk;
3use crate::{Entry, Instance};
4use std::ffi::CStr;
5use std::mem;
6use std::ptr;
7
8#[derive(Clone)]
9pub struct GetPhysicalDeviceProperties2 {
10 fp: vk::KhrGetPhysicalDeviceProperties2Fn,
11}
12
13impl GetPhysicalDeviceProperties2 {
14 pub fn new(entry: &Entry, instance: &Instance) -> Self {
15 let fp = vk::KhrGetPhysicalDeviceProperties2Fn::load(|name| unsafe {
16 mem::transmute(entry.get_instance_proc_addr(instance.handle(), name.as_ptr()))
17 });
18 Self { fp }
19 }
20
21 #[inline]
23 pub unsafe fn get_physical_device_features2(
24 &self,
25 physical_device: vk::PhysicalDevice,
26 features: &mut vk::PhysicalDeviceFeatures2KHR,
27 ) {
28 (self.fp.get_physical_device_features2_khr)(physical_device, features);
29 }
30
31 #[inline]
33 pub unsafe fn get_physical_device_format_properties2(
34 &self,
35 physical_device: vk::PhysicalDevice,
36 format: vk::Format,
37 format_properties: &mut vk::FormatProperties2KHR,
38 ) {
39 (self.fp.get_physical_device_format_properties2_khr)(
40 physical_device,
41 format,
42 format_properties,
43 );
44 }
45
46 #[inline]
48 pub unsafe fn get_physical_device_image_format_properties2(
49 &self,
50 physical_device: vk::PhysicalDevice,
51 image_format_info: &vk::PhysicalDeviceImageFormatInfo2KHR,
52 image_format_properties: &mut vk::ImageFormatProperties2KHR,
53 ) -> VkResult<()> {
54 (self.fp.get_physical_device_image_format_properties2_khr)(
55 physical_device,
56 image_format_info,
57 image_format_properties,
58 )
59 .result()
60 }
61
62 #[inline]
64 pub unsafe fn get_physical_device_memory_properties2(
65 &self,
66 physical_device: vk::PhysicalDevice,
67 memory_properties: &mut vk::PhysicalDeviceMemoryProperties2KHR,
68 ) {
69 (self.fp.get_physical_device_memory_properties2_khr)(physical_device, memory_properties);
70 }
71
72 #[inline]
74 pub unsafe fn get_physical_device_properties2(
75 &self,
76 physical_device: vk::PhysicalDevice,
77 properties: &mut vk::PhysicalDeviceProperties2KHR,
78 ) {
79 (self.fp.get_physical_device_properties2_khr)(physical_device, properties);
80 }
81
82 #[inline]
84 pub unsafe fn get_physical_device_queue_family_properties2_len(
85 &self,
86 physical_device: vk::PhysicalDevice,
87 ) -> usize {
88 let mut count = 0;
89 (self.fp.get_physical_device_queue_family_properties2_khr)(
90 physical_device,
91 &mut count,
92 ptr::null_mut(),
93 );
94 count as usize
95 }
96
97 #[inline]
102 pub unsafe fn get_physical_device_queue_family_properties2(
103 &self,
104 physical_device: vk::PhysicalDevice,
105 out: &mut [vk::QueueFamilyProperties2KHR],
106 ) {
107 let mut count = out.len() as u32;
108 (self.fp.get_physical_device_queue_family_properties2_khr)(
109 physical_device,
110 &mut count,
111 out.as_mut_ptr(),
112 );
113 assert_eq!(count as usize, out.len());
114 }
115
116 #[inline]
118 pub unsafe fn get_physical_device_sparse_image_format_properties2_len(
119 &self,
120 physical_device: vk::PhysicalDevice,
121 format_info: &vk::PhysicalDeviceSparseImageFormatInfo2KHR,
122 ) -> usize {
123 let mut count = 0;
124 (self
125 .fp
126 .get_physical_device_sparse_image_format_properties2_khr)(
127 physical_device,
128 format_info,
129 &mut count,
130 ptr::null_mut(),
131 );
132 count as usize
133 }
134
135 #[inline]
140 pub unsafe fn get_physical_device_sparse_image_format_properties2(
141 &self,
142 physical_device: vk::PhysicalDevice,
143 format_info: &vk::PhysicalDeviceSparseImageFormatInfo2KHR,
144 out: &mut [vk::SparseImageFormatProperties2KHR],
145 ) {
146 let mut count = out.len() as u32;
147 (self
148 .fp
149 .get_physical_device_sparse_image_format_properties2_khr)(
150 physical_device,
151 format_info,
152 &mut count,
153 out.as_mut_ptr(),
154 );
155 assert_eq!(count as usize, out.len());
156 }
157
158 #[inline]
159 pub const fn name() -> &'static CStr {
160 vk::KhrGetPhysicalDeviceProperties2Fn::name()
161 }
162
163 #[inline]
164 pub fn fp(&self) -> &vk::KhrGetPhysicalDeviceProperties2Fn {
165 &self.fp
166 }
167}