Add basic support for VK_KHR_portability_subset

This commit is contained in:
Dzmitry Malyshau 2020-08-22 00:43:27 -04:00 committed by Dzmitry Malyshau
parent bb40160a6a
commit 7034f366b3
2 changed files with 38 additions and 38 deletions

View file

@ -250,10 +250,11 @@ pub unsafe extern "C" fn gfxGetPhysicalDeviceFeatures2KHR(
data.features = conv::features_from_hal(features); data.features = conv::features_from_hal(features);
data.pNext data.pNext
} }
VkStructureType::VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_PORTABILITY_SUBSET_FEATURES_EXTX => { VkStructureType::VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_PORTABILITY_SUBSET_FEATURES_KHR => {
let data = (ptr as *mut VkPhysicalDevicePortabilitySubsetFeaturesEXTX) let data = (ptr as *mut VkPhysicalDevicePortabilitySubsetFeaturesKHR)
.as_mut() .as_mut()
.unwrap(); .unwrap();
data.events = VK_TRUE;
if features.contains(hal::Features::TRIANGLE_FAN) { if features.contains(hal::Features::TRIANGLE_FAN) {
data.triangleFans = VK_TRUE; data.triangleFans = VK_TRUE;
} }
@ -263,9 +264,13 @@ pub unsafe extern "C" fn gfxGetPhysicalDeviceFeatures2KHR(
if features.contains(hal::Features::SAMPLER_MIP_LOD_BIAS) { if features.contains(hal::Features::SAMPLER_MIP_LOD_BIAS) {
data.samplerMipLodBias = VK_TRUE; data.samplerMipLodBias = VK_TRUE;
} }
//TODO: turn this into a feature flag //TODO: turn these into a feature flags
if !cfg!(feature = "gfx-backend-metal") { if cfg!(feature = "gfx-backend-metal") {
data.standardImageViews = VK_TRUE; data.constantAlphaColorBlendFactors = VK_TRUE;
data.imageViewFormatReinterpretation = VK_TRUE;
}
if cfg!(feature = "gfx-backend-dx12") {
data.vertexAttributeAccessBeyondStride = VK_TRUE;
} }
data.pNext data.pNext
} }
@ -353,21 +358,6 @@ pub unsafe extern "C" fn gfxGetPhysicalDeviceImageFormatProperties2KHR(
properties = get_physical_device_image_format_properties(adapter, data); properties = get_physical_device_image_format_properties(adapter, data);
data.pNext data.pNext
} }
VkStructureType::VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_IMAGE_VIEW_SUPPORT_EXTX => {
let data = (ptr as *const VkPhysicalDeviceImageViewSupportEXTX)
.as_ref()
.unwrap();
#[cfg(feature = "gfx-backend-metal")]
{
if !adapter.physical_device.supports_swizzle(
conv::map_format(data.format).unwrap(),
conv::map_swizzle(data.components),
) {
return VkResult::VK_ERROR_FORMAT_NOT_SUPPORTED;
}
}
data.pNext
}
other => { other => {
warn!("Unrecognized {:?}, skipping", other); warn!("Unrecognized {:?}, skipping", other);
(ptr as *const VkBaseStruct).as_ref().unwrap().pNext (ptr as *const VkBaseStruct).as_ref().unwrap().pNext
@ -438,9 +428,9 @@ pub unsafe extern "C" fn gfxGetPhysicalDeviceProperties2KHR(
gfxGetPhysicalDeviceProperties(adapter, &mut data.properties); gfxGetPhysicalDeviceProperties(adapter, &mut data.properties);
data.pNext data.pNext
} }
VkStructureType::VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_PORTABILITY_SUBSET_PROPERTIES_EXTX => { VkStructureType::VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_PORTABILITY_SUBSET_PROPERTIES_KHR => {
let data = let data =
(ptr as *mut VkPhysicalDevicePortabilitySubsetPropertiesEXTX).as_mut().unwrap() (ptr as *mut VkPhysicalDevicePortabilitySubsetPropertiesKHR).as_mut().unwrap()
; ;
let limits = adapter.physical_device.limits(); let limits = adapter.physical_device.limits();
data.minVertexInputBindingStrideAlignment = limits.min_vertex_input_binding_stride_alignment as u32; data.minVertexInputBindingStrideAlignment = limits.min_vertex_input_binding_stride_alignment as u32;
@ -988,7 +978,7 @@ lazy_static! {
vec![ vec![
VK_KHR_SWAPCHAIN_EXTENSION_NAME, VK_KHR_SWAPCHAIN_EXTENSION_NAME,
VK_KHR_MAINTENANCE1_EXTENSION_NAME, VK_KHR_MAINTENANCE1_EXTENSION_NAME,
VK_EXTX_PORTABILITY_SUBSET_EXTENSION_NAME, VK_KHR_PORTABILITY_SUBSET_EXTENSION_NAME,
] ]
}; };
@ -1003,8 +993,8 @@ lazy_static! {
specVersion: VK_KHR_MAINTENANCE1_SPEC_VERSION, specVersion: VK_KHR_MAINTENANCE1_SPEC_VERSION,
}, },
VkExtensionProperties { VkExtensionProperties {
extensionName: [0; 256], // VK_EXTX_PORTABILITY_SUBSET_EXTENSION_NAME extensionName: [0; 256], // VK_KHR_PORTABILITY_SUBSET_EXTENSION_NAME
specVersion: VK_EXTX_PORTABILITY_SUBSET_SPEC_VERSION, specVersion: VK_KHR_PORTABILITY_SUBSET_SPEC_VERSION,
}, },
]; ];

View file

@ -523,10 +523,10 @@ pub const VK_EXT_discard_rectangles: ::std::os::raw::c_uint = 1;
pub const VK_EXT_DISCARD_RECTANGLES_SPEC_VERSION: ::std::os::raw::c_uint = 1; pub const VK_EXT_DISCARD_RECTANGLES_SPEC_VERSION: ::std::os::raw::c_uint = 1;
pub const VK_EXT_DISCARD_RECTANGLES_EXTENSION_NAME: &'static [u8; 26usize] = pub const VK_EXT_DISCARD_RECTANGLES_EXTENSION_NAME: &'static [u8; 26usize] =
b"VK_EXT_discard_rectangles\x00"; b"VK_EXT_discard_rectangles\x00";
pub const VK_EXTX_portability_subset: ::std::os::raw::c_uint = 1; pub const VK_KHR_portability_subset: ::std::os::raw::c_uint = 1;
pub const VK_EXTX_PORTABILITY_SUBSET_SPEC_VERSION: ::std::os::raw::c_uint = 1; pub const VK_KHR_PORTABILITY_SUBSET_SPEC_VERSION: ::std::os::raw::c_uint = 1;
pub const VK_EXTX_PORTABILITY_SUBSET_EXTENSION_NAME: &'static [u8; 27usize] = pub const VK_KHR_PORTABILITY_SUBSET_EXTENSION_NAME: &'static [u8; 26usize] =
b"VK_EXTX_portability_subset\x00"; b"VK_KHR_portability_subset\x00";
pub type wchar_t = ::std::os::raw::c_int; pub type wchar_t = ::std::os::raw::c_int;
#[repr(C)] #[repr(C)]
@ -832,8 +832,8 @@ pub enum VkStructureType {
VK_STRUCTURE_TYPE_IOS_SURFACE_CREATE_INFO_MVK = 1000122000, VK_STRUCTURE_TYPE_IOS_SURFACE_CREATE_INFO_MVK = 1000122000,
VK_STRUCTURE_TYPE_MACOS_SURFACE_CREATE_INFO_MVK = 1000123000, VK_STRUCTURE_TYPE_MACOS_SURFACE_CREATE_INFO_MVK = 1000123000,
VK_STRUCTURE_TYPE_METAL_SURFACE_CREATE_INFO_EXT = 1000248000, VK_STRUCTURE_TYPE_METAL_SURFACE_CREATE_INFO_EXT = 1000248000,
VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_PORTABILITY_SUBSET_FEATURES_EXTX = 1000163000, VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_PORTABILITY_SUBSET_FEATURES_KHR = 1000164000,
VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_PORTABILITY_SUBSET_PROPERTIES_EXTX = 1000163001, VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_PORTABILITY_SUBSET_PROPERTIES_KHR = 1000164001,
VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_IMAGE_VIEW_SUPPORT_EXTX = 100163002, VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_IMAGE_VIEW_SUPPORT_EXTX = 100163002,
VK_STRUCTURE_TYPE_MAX_ENUM = 2147483647, VK_STRUCTURE_TYPE_MAX_ENUM = 2147483647,
} }
@ -7536,28 +7536,38 @@ pub type PFN_vkGetPhysicalDeviceWin32PresentationSupportKHR = ::std::option::Opt
#[repr(C)] #[repr(C)]
#[derive(Debug, Copy)] #[derive(Debug, Copy)]
pub struct VkPhysicalDevicePortabilitySubsetFeaturesEXTX { pub struct VkPhysicalDevicePortabilitySubsetFeaturesKHR {
pub sType: VkStructureType, pub sType: VkStructureType,
pub pNext: *const ::std::os::raw::c_void, pub pNext: *const ::std::os::raw::c_void,
pub triangleFans: VkBool32, pub constantAlphaColorBlendFactors: VkBool32,
pub separateStencilMaskRef: VkBool32,
pub events: VkBool32, pub events: VkBool32,
pub standardImageViews: VkBool32, pub imageViewFormatReinterpretation: VkBool32,
pub imageViewFormatSwizzle: VkBool32,
pub imageView2DOn3DImage: VkBool32,
pub multisampleArrayImage: VkBool32,
pub mutableComparisonSamplers: VkBool32,
pub pointPolygons: VkBool32,
pub samplerMipLodBias: VkBool32, pub samplerMipLodBias: VkBool32,
pub separateStencilMaskRef: VkBool32,
pub shaderSampleRateInterpolationFunctions: VkBool32,
pub tessellationIsolines: VkBool32,
pub tessellationPointMode: VkBool32,
pub triangleFans: VkBool32,
pub vertexAttributeAccessBeyondStride: VkBool32,
} }
impl Clone for VkPhysicalDevicePortabilitySubsetFeaturesEXTX { impl Clone for VkPhysicalDevicePortabilitySubsetFeaturesKHR {
fn clone(&self) -> Self { fn clone(&self) -> Self {
*self *self
} }
} }
#[repr(C)] #[repr(C)]
#[derive(Debug, Copy)] #[derive(Debug, Copy)]
pub struct VkPhysicalDevicePortabilitySubsetPropertiesEXTX { pub struct VkPhysicalDevicePortabilitySubsetPropertiesKHR {
pub sType: VkStructureType, pub sType: VkStructureType,
pub pNext: *const ::std::os::raw::c_void, pub pNext: *const ::std::os::raw::c_void,
pub minVertexInputBindingStrideAlignment: u32, pub minVertexInputBindingStrideAlignment: u32,
} }
impl Clone for VkPhysicalDevicePortabilitySubsetPropertiesEXTX { impl Clone for VkPhysicalDevicePortabilitySubsetPropertiesKHR {
fn clone(&self) -> Self { fn clone(&self) -> Self {
*self *self
} }