ash/extensions/khr/
get_physical_device_properties2.rs
1use 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 pub unsafe fn get_physical_device_features2(
23 &self,
24 physical_device: vk::PhysicalDevice,
25 features: &mut vk::PhysicalDeviceFeatures2KHR,
26 ) {
27 (self.fp.get_physical_device_features2_khr)(physical_device, features);
28 }
29
30 pub unsafe fn get_physical_device_format_properties2(
32 &self,
33 physical_device: vk::PhysicalDevice,
34 format: vk::Format,
35 format_properties: &mut vk::FormatProperties2KHR,
36 ) {
37 (self.fp.get_physical_device_format_properties2_khr)(
38 physical_device,
39 format,
40 format_properties,
41 );
42 }
43
44 pub unsafe fn get_physical_device_image_format_properties2(
46 &self,
47 physical_device: vk::PhysicalDevice,
48 image_format_info: &vk::PhysicalDeviceImageFormatInfo2KHR,
49 image_format_properties: &mut vk::ImageFormatProperties2KHR,
50 ) -> VkResult<()> {
51 (self.fp.get_physical_device_image_format_properties2_khr)(
52 physical_device,
53 image_format_info,
54 image_format_properties,
55 )
56 .result()
57 }
58
59 pub unsafe fn get_physical_device_memory_properties2(
61 &self,
62 physical_device: vk::PhysicalDevice,
63 memory_properties: &mut vk::PhysicalDeviceMemoryProperties2KHR,
64 ) {
65 (self.fp.get_physical_device_memory_properties2_khr)(physical_device, memory_properties);
66 }
67
68 pub unsafe fn get_physical_device_properties2(
70 &self,
71 physical_device: vk::PhysicalDevice,
72 properties: &mut vk::PhysicalDeviceProperties2KHR,
73 ) {
74 (self.fp.get_physical_device_properties2_khr)(physical_device, properties);
75 }
76
77 pub unsafe fn get_physical_device_queue_family_properties2_len(
79 &self,
80 physical_device: vk::PhysicalDevice,
81 ) -> usize {
82 let mut count = 0;
83 (self.fp.get_physical_device_queue_family_properties2_khr)(
84 physical_device,
85 &mut count,
86 ptr::null_mut(),
87 );
88 count as usize
89 }
90
91 pub unsafe fn get_physical_device_queue_family_properties2(
96 &self,
97 physical_device: vk::PhysicalDevice,
98 out: &mut [vk::QueueFamilyProperties2KHR],
99 ) {
100 let mut count = out.len() as u32;
101 (self.fp.get_physical_device_queue_family_properties2_khr)(
102 physical_device,
103 &mut count,
104 out.as_mut_ptr(),
105 );
106 assert_eq!(count as usize, out.len());
107 }
108
109 pub unsafe fn get_physical_device_sparse_image_format_properties2_len(
111 &self,
112 physical_device: vk::PhysicalDevice,
113 format_info: &vk::PhysicalDeviceSparseImageFormatInfo2KHR,
114 ) -> usize {
115 let mut count = 0;
116 (self
117 .fp
118 .get_physical_device_sparse_image_format_properties2_khr)(
119 physical_device,
120 format_info,
121 &mut count,
122 ptr::null_mut(),
123 );
124 count as usize
125 }
126
127 pub unsafe fn get_physical_device_sparse_image_format_properties2(
132 &self,
133 physical_device: vk::PhysicalDevice,
134 format_info: &vk::PhysicalDeviceSparseImageFormatInfo2KHR,
135 out: &mut [vk::SparseImageFormatProperties2KHR],
136 ) {
137 let mut count = out.len() as u32;
138 (self
139 .fp
140 .get_physical_device_sparse_image_format_properties2_khr)(
141 physical_device,
142 format_info,
143 &mut count,
144 out.as_mut_ptr(),
145 );
146 assert_eq!(count as usize, out.len());
147 }
148
149 pub const fn name() -> &'static CStr {
150 vk::KhrGetPhysicalDeviceProperties2Fn::name()
151 }
152
153 pub fn fp(&self) -> &vk::KhrGetPhysicalDeviceProperties2Fn {
154 &self.fp
155 }
156}