| 1 | //! <https://registry.khronos.org/vulkan/specs/1.3-extensions/man/html/VK_AMD_shader_info.html> |
| 2 | |
| 3 | use crate::prelude::*; |
| 4 | use crate::vk; |
| 5 | use alloc::vec::Vec; |
| 6 | use core::mem; |
| 7 | |
| 8 | impl crate::amd::shader_info::Device { |
| 9 | /// <https://registry.khronos.org/vulkan/specs/1.3-extensions/man/html/vkGetShaderInfoAMD.html> with [`vk::ShaderInfoTypeAMD::STATISTICS`] |
| 10 | #[inline] |
| 11 | pub unsafe fn get_shader_info_statistics( |
| 12 | &self, |
| 13 | pipeline: vk::Pipeline, |
| 14 | shader_stage: vk::ShaderStageFlags, |
| 15 | ) -> VkResult<vk::ShaderStatisticsInfoAMD> { |
| 16 | let mut info = mem::MaybeUninit::<vk::ShaderStatisticsInfoAMD>::uninit(); |
| 17 | let mut size = mem::size_of_val(&info); |
| 18 | (self.fp.get_shader_info_amd)( |
| 19 | self.handle, |
| 20 | pipeline, |
| 21 | shader_stage, |
| 22 | vk::ShaderInfoTypeAMD::STATISTICS, |
| 23 | &mut size, |
| 24 | info.as_mut_ptr().cast(), |
| 25 | ) |
| 26 | .result()?; |
| 27 | assert_eq!(size, mem::size_of_val(&info)); |
| 28 | Ok(info.assume_init()) |
| 29 | } |
| 30 | |
| 31 | /// <https://registry.khronos.org/vulkan/specs/1.3-extensions/man/html/vkGetShaderInfoAMD.html> with [`vk::ShaderInfoTypeAMD::BINARY`] |
| 32 | #[inline] |
| 33 | pub unsafe fn get_shader_info_binary( |
| 34 | &self, |
| 35 | pipeline: vk::Pipeline, |
| 36 | shader_stage: vk::ShaderStageFlags, |
| 37 | ) -> VkResult<Vec<u8>> { |
| 38 | read_into_uninitialized_vector(|count, data: *mut u8| { |
| 39 | (self.fp.get_shader_info_amd)( |
| 40 | self.handle, |
| 41 | pipeline, |
| 42 | shader_stage, |
| 43 | vk::ShaderInfoTypeAMD::BINARY, |
| 44 | count, |
| 45 | data.cast(), |
| 46 | ) |
| 47 | }) |
| 48 | } |
| 49 | |
| 50 | /// <https://registry.khronos.org/vulkan/specs/1.3-extensions/man/html/vkGetShaderInfoAMD.html> with [`vk::ShaderInfoTypeAMD::DISASSEMBLY`] |
| 51 | #[inline] |
| 52 | pub unsafe fn get_shader_info_disassembly( |
| 53 | &self, |
| 54 | pipeline: vk::Pipeline, |
| 55 | shader_stage: vk::ShaderStageFlags, |
| 56 | ) -> VkResult<Vec<u8>> { |
| 57 | read_into_uninitialized_vector(|count, data: *mut u8| { |
| 58 | (self.fp.get_shader_info_amd)( |
| 59 | self.handle, |
| 60 | pipeline, |
| 61 | shader_stage, |
| 62 | vk::ShaderInfoTypeAMD::DISASSEMBLY, |
| 63 | count, |
| 64 | data.cast(), |
| 65 | ) |
| 66 | }) |
| 67 | } |
| 68 | } |