Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

extensions/ext: Add VK_EXT_sample_locations #616

Merged
merged 1 commit into from
May 10, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions Changelog.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0

### Added

- Added `VK_EXT_sample_locations` device extension (#616)
- Update Vulkan-Headers to 1.3.211 (#605, #608)

### Removed
Expand Down
2 changes: 2 additions & 0 deletions ash/src/extensions/ext/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ pub use self::headless_surface::HeadlessSurface;
pub use self::metal_surface::MetalSurface;
pub use self::physical_device_drm::PhysicalDeviceDrm;
pub use self::private_data::PrivateData;
pub use self::sample_locations::SampleLocations;
pub use self::tooling_info::ToolingInfo;

mod buffer_device_address;
Expand All @@ -28,4 +29,5 @@ mod headless_surface;
mod metal_surface;
mod physical_device_drm;
mod private_data;
mod sample_locations;
mod tooling_info;
50 changes: 50 additions & 0 deletions ash/src/extensions/ext/sample_locations.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
use crate::vk;
use crate::{Entry, Instance};
use std::ffi::CStr;
use std::mem;

/// <https://www.khronos.org/registry/vulkan/specs/1.3-extensions/man/html/VK_EXT_sample_locations.html>
#[derive(Clone)]
pub struct SampleLocations {
fp: vk::ExtSampleLocationsFn,
}

impl SampleLocations {
pub fn new(entry: &Entry, instance: &Instance) -> Self {
let fp = vk::ExtSampleLocationsFn::load(|name| unsafe {
mem::transmute(entry.get_instance_proc_addr(instance.handle(), name.as_ptr()))
});
Self { fp }
}

/// <https://www.khronos.org/registry/vulkan/specs/1.3-extensions/man/html/vkGetPhysicalDeviceMultisamplePropertiesEXT.html>
pub unsafe fn get_physical_device_multisample_properties(
&self,
physical_device: vk::PhysicalDevice,
samples: vk::SampleCountFlags,
multisample_properties: &mut vk::MultisamplePropertiesEXT,
) {
(self.fp.get_physical_device_multisample_properties_ext)(
physical_device,
samples,
multisample_properties,
)
}

/// <https://www.khronos.org/registry/vulkan/specs/1.3-extensions/man/html/vkCmdSetSampleLocationsEXT.html>
pub unsafe fn cmd_set_sample_locations(
&self,
command_buffer: vk::CommandBuffer,
sample_locations_info: &vk::SampleLocationsInfoEXT,
) {
(self.fp.cmd_set_sample_locations_ext)(command_buffer, sample_locations_info)
}

pub const fn name() -> &'static CStr {
vk::ExtSampleLocationsFn::name()
}

pub fn fp(&self) -> &vk::ExtSampleLocationsFn {
&self.fp
}
}