Skip to content

Commit

Permalink
extensions/khr: Enable passing pNext-initialized struct to `get_phy…
Browse files Browse the repository at this point in the history
…sical_device_surface_capabilities2`

Version 2 of `get_physical_device_surface_capabilities` and the matching
`vk::SurfaceCapabilitiesKHR` struct exist solely to provide an `sType`
and `pNext` field to allow extending the original query with additional
data via extension structs.  However, this API when introduced in #530
only returns the default-initialized struct making it just as
constrained as `get_physical_device_surface_capabilities()`.  Solve this
by taking `vk::SurfaceCapabilities2KHR` as `&mut` just like any similar
API.
  • Loading branch information
MarijnS95 committed Apr 16, 2023
1 parent 23da5db commit c7d6b00
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 4 deletions.
1 change: 1 addition & 0 deletions Changelog.md
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
- Inlined struct setters (#602)
- Bumped MSRV from 1.59 to 1.60 (#709)
- Replaced `const fn name()` with associated `NAME` constants (#715)
- `VK_KHR_get_surface_capabilities2`: Enable passing `pNext`-initialized struct to `get_physical_device_surface_capabilities2` (#744)

### Removed

Expand Down
9 changes: 5 additions & 4 deletions ash/src/extensions/khr/get_surface_capabilities2.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ use crate::{Entry, Instance};
use std::ffi::CStr;
use std::mem;

/// <https://registry.khronos.org/vulkan/specs/1.3-extensions/man/html/VK_KHR_get_surface_capabilities2.html>
#[derive(Clone)]
pub struct GetSurfaceCapabilities2 {
fp: vk::KhrGetSurfaceCapabilities2Fn,
Expand All @@ -23,14 +24,14 @@ impl GetSurfaceCapabilities2 {
&self,
physical_device: vk::PhysicalDevice,
surface_info: &vk::PhysicalDeviceSurfaceInfo2KHR,
) -> VkResult<vk::SurfaceCapabilities2KHR> {
let mut surface_capabilities = Default::default();
surface_capabilities: &mut vk::SurfaceCapabilities2KHR,
) -> VkResult<()> {
(self.fp.get_physical_device_surface_capabilities2_khr)(
physical_device,
surface_info,
&mut surface_capabilities,
surface_capabilities,
)
.result_with_success(surface_capabilities)
.result()
}

/// Retrieve the number of elements to pass to [`get_physical_device_surface_formats2()`][Self::get_physical_device_surface_formats2()]
Expand Down

0 comments on commit c7d6b00

Please sign in to comment.