Re-allow vk backend on Apple platforms via vulkan-portability feature

This commit is contained in:
Jinlei Li
2022-02-18 07:24:00 +08:00
committed by Dzmitry Malyshau
parent c1dcd6ddee
commit fa35c0a0f4
7 changed files with 16 additions and 8 deletions

View File

@@ -21,6 +21,7 @@ replay = ["serde", "wgt/replay", "arrayvec/serde", "naga/deserialize"]
# Enable serializable compute/render passes, and bundle encoders.
serial-pass = ["serde", "wgt/serde", "arrayvec/serde"]
id32 = []
vulkan-portability = ["hal/vulkan"]
[dependencies]
arrayvec = "0.7"

View File

@@ -7,7 +7,7 @@ fn main() {
unix_wo_apple: {all(unix, not(apple))},
// Backends
vulkan: { all(not(wasm), any(windows, unix_wo_apple)) },
vulkan: { all(not(wasm), any(windows, unix_wo_apple, feature = "vulkan-portability")) },
metal: { all(not(wasm), apple) },
dx12: { all(not(wasm), windows) },
dx11: { all(false, not(wasm), windows) },

View File

@@ -514,6 +514,8 @@ impl<G: GlobalIdentityHandlerFactory> Global<G> {
},
//acquired_texture: None,
}),
#[cfg(vulkan)]
vulkan: None,
#[cfg(gl)]
gl: None,
};

View File

@@ -202,7 +202,10 @@ macro_rules! gfx_select {
// Note: For some reason the cfg aliases defined in build.rs don't succesfully apply in this
// macro so we must specify their equivalents manually
match $id.backend() {
#[cfg(all(not(target_arch = "wasm32"), not(target_os = "ios"), not(target_os = "macos")))]
#[cfg(any(
all(not(target_arch = "wasm32"), not(target_os = "ios"), not(target_os = "macos")),
feature = "vulkan-portability"
))]
wgt::Backend::Vulkan => $global.$method::<$crate::api::Vulkan>( $($param),* ),
#[cfg(all(not(target_arch = "wasm32"), any(target_os = "ios", target_os = "macos")))]
wgt::Backend::Metal => $global.$method::<$crate::api::Metal>( $($param),* ),

View File

@@ -210,12 +210,9 @@ impl crate::Surface<super::Api> for super::Surface {
render_layer.set_presents_with_transaction(self.present_with_transaction);
// opt-in to Metal EDR
// EDR potentially more power used in display and more bandwidth, memory footprint.
#[cfg(target_os = "macos")]
{
let wants_edr = self.raw_swapchain_format == mtl::MTLPixelFormat::RGBA16Float;
if wants_edr != render_layer.wants_extended_dynamic_range_content() {
render_layer.set_wants_extended_dynamic_range_content(wants_edr);
}
let wants_edr = self.raw_swapchain_format == mtl::MTLPixelFormat::RGBA16Float;
if wants_edr != render_layer.wants_extended_dynamic_range_content() {
render_layer.set_wants_extended_dynamic_range_content(wants_edr);
}
// this gets ignored on iOS for certain OS/device combinations (iphone5s iOS 10.3)

View File

@@ -630,6 +630,9 @@ impl PhysicalDeviceCapabilities {
extensions.push(vk::ExtDepthClipEnableFn::name());
}
#[cfg(any(target_os = "macos", target_os = "ios"))]
extensions.push(vk::KhrPortabilitySubsetFn::name());
extensions
}
@@ -1494,6 +1497,7 @@ impl crate::Adapter<super::Api> for super::Adapter {
wgt::TextureFormat::Rgba8UnormSrgb,
wgt::TextureFormat::Bgra8Unorm,
wgt::TextureFormat::Bgra8UnormSrgb,
wgt::TextureFormat::Rgba16Float,
];
let formats = supported_formats
.iter()

View File

@@ -84,6 +84,7 @@ replay = ["serde", "wgc/replay"]
angle = ["wgc/angle"]
webgl = ["wgc"]
emscripten = ["webgl"]
vulkan-portability = ["wgc/vulkan-portability"]
[target.'cfg(not(target_arch = "wasm32"))'.dependencies.wgc]
package = "wgpu-core"