mirror of
https://github.com/italicsjenga/vello.git
synced 2025-01-10 12:41:30 +11:00
Upgrade to Ash 0.33
This was motivated by experiments with the Vulkan memory model. To use that, we actually need to explicitly enable the relevant feature on device creation time. That's a lot easier to do now that push_next works on the structs in that chain. This PR doesn't do that though, it only upgrades the dependency and cleans up deprecations.
This commit is contained in:
parent
b0b0f33c3c
commit
d04ae44618
22
Cargo.lock
generated
22
Cargo.lock
generated
|
@ -44,18 +44,18 @@ checksum = "23b62fc65de8e4e7f52534fb52b0f3ed04746ae267519eef2a83941e8085068b"
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "ash"
|
name = "ash"
|
||||||
version = "0.31.0"
|
version = "0.33.3+1.2.191"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "c69a8137596e84c22d57f3da1b5de1d4230b1742a710091c85f4d7ce50f00f38"
|
checksum = "cc4f1d82f164f838ae413296d1131aa6fa79b917d25bebaa7033d25620c09219"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"libloading",
|
"libloading 0.7.1",
|
||||||
]
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "ash-window"
|
name = "ash-window"
|
||||||
version = "0.5.0"
|
version = "0.7.0"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "905c4ca25f752e7ab3c3e8f2882625f876e4c3ea5feffbc83f81d697e043afd6"
|
checksum = "12f91ce4c6be1a2ba99d3d6cd57d5bae9ac6d6f903b5ae53d6b1dee2edf872af"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"ash",
|
"ash",
|
||||||
"raw-window-handle",
|
"raw-window-handle",
|
||||||
|
@ -348,7 +348,7 @@ version = "0.4.2"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "b11f15d1e3268f140f68d390637d5e76d849782d971ae7063e0da69fe9709a76"
|
checksum = "b11f15d1e3268f140f68d390637d5e76d849782d971ae7063e0da69fe9709a76"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"libloading",
|
"libloading 0.6.5",
|
||||||
]
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
|
@ -497,6 +497,16 @@ dependencies = [
|
||||||
"winapi 0.3.9",
|
"winapi 0.3.9",
|
||||||
]
|
]
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "libloading"
|
||||||
|
version = "0.7.1"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "c0cf036d15402bea3c5d4de17b3fce76b3e4a56ebc1f577be0e7a72f7c607cf0"
|
||||||
|
dependencies = [
|
||||||
|
"cfg-if 1.0.0",
|
||||||
|
"winapi 0.3.9",
|
||||||
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "lock_api"
|
name = "lock_api"
|
||||||
version = "0.4.1"
|
version = "0.4.1"
|
||||||
|
|
|
@ -7,8 +7,8 @@ license = "MIT/Apache-2.0"
|
||||||
edition = "2018"
|
edition = "2018"
|
||||||
|
|
||||||
[dependencies]
|
[dependencies]
|
||||||
ash = "0.31"
|
ash = "0.33"
|
||||||
ash-window = "0.5"
|
ash-window = "0.7"
|
||||||
raw-window-handle = "0.3"
|
raw-window-handle = "0.3"
|
||||||
bitflags = "1.2.1"
|
bitflags = "1.2.1"
|
||||||
smallvec = "1.6.1"
|
smallvec = "1.6.1"
|
||||||
|
|
|
@ -7,7 +7,6 @@ use std::os::raw::c_char;
|
||||||
use std::sync::Arc;
|
use std::sync::Arc;
|
||||||
|
|
||||||
use ash::extensions::{ext::DebugUtils, khr};
|
use ash::extensions::{ext::DebugUtils, khr};
|
||||||
use ash::version::{DeviceV1_0, EntryV1_0, InstanceV1_0, InstanceV1_1};
|
|
||||||
use ash::{vk, Device, Entry, Instance};
|
use ash::{vk, Device, Entry, Instance};
|
||||||
|
|
||||||
use smallvec::SmallVec;
|
use smallvec::SmallVec;
|
||||||
|
@ -21,7 +20,6 @@ pub struct VkInstance {
|
||||||
#[allow(unused)]
|
#[allow(unused)]
|
||||||
entry: Entry,
|
entry: Entry,
|
||||||
instance: Instance,
|
instance: Instance,
|
||||||
get_phys_dev_props: Option<vk::KhrGetPhysicalDeviceProperties2Fn>,
|
|
||||||
vk_version: u32,
|
vk_version: u32,
|
||||||
_dbg_loader: Option<DebugUtils>,
|
_dbg_loader: Option<DebugUtils>,
|
||||||
_dbg_callbk: Option<vk::DebugUtilsMessengerEXT>,
|
_dbg_callbk: Option<vk::DebugUtilsMessengerEXT>,
|
||||||
|
@ -178,8 +176,6 @@ impl VkInstance {
|
||||||
if cfg!(debug_assertions) {
|
if cfg!(debug_assertions) {
|
||||||
has_debug_ext = exts.try_add(DebugUtils::name());
|
has_debug_ext = exts.try_add(DebugUtils::name());
|
||||||
}
|
}
|
||||||
// We'll need this to do runtime query of descriptor indexing.
|
|
||||||
let has_phys_dev_props = exts.try_add(vk::KhrGetPhysicalDeviceProperties2Fn::name());
|
|
||||||
if let Some(ref handle) = window_handle {
|
if let Some(ref handle) = window_handle {
|
||||||
for ext in ash_window::enumerate_required_extensions(*handle)? {
|
for ext in ash_window::enumerate_required_extensions(*handle)? {
|
||||||
exts.try_add(ext);
|
exts.try_add(ext);
|
||||||
|
@ -188,12 +184,12 @@ impl VkInstance {
|
||||||
|
|
||||||
let supported_version = entry
|
let supported_version = entry
|
||||||
.try_enumerate_instance_version()?
|
.try_enumerate_instance_version()?
|
||||||
.unwrap_or(vk::make_version(1, 0, 0));
|
.unwrap_or(vk::make_api_version(0, 1, 0, 0));
|
||||||
let vk_version = if supported_version >= vk::make_version(1, 1, 0) {
|
let vk_version = if supported_version >= vk::make_api_version(0, 1, 1, 0) {
|
||||||
// We need Vulkan 1.1 to do subgroups; most other things can be extensions.
|
// We need Vulkan 1.1 to do subgroups; most other things can be extensions.
|
||||||
vk::make_version(1, 1, 0)
|
vk::make_api_version(0, 1, 1, 0)
|
||||||
} else {
|
} else {
|
||||||
vk::make_version(1, 0, 0)
|
vk::make_api_version(0, 1, 0, 0)
|
||||||
};
|
};
|
||||||
|
|
||||||
let instance = entry.create_instance(
|
let instance = entry.create_instance(
|
||||||
|
@ -235,20 +231,9 @@ impl VkInstance {
|
||||||
None => None,
|
None => None,
|
||||||
};
|
};
|
||||||
|
|
||||||
let get_phys_dev_props = if has_phys_dev_props {
|
|
||||||
Some(vk::KhrGetPhysicalDeviceProperties2Fn::load(|name| {
|
|
||||||
std::mem::transmute(
|
|
||||||
entry.get_instance_proc_addr(instance.handle(), name.as_ptr()),
|
|
||||||
)
|
|
||||||
}))
|
|
||||||
} else {
|
|
||||||
None
|
|
||||||
};
|
|
||||||
|
|
||||||
let vk_instance = VkInstance {
|
let vk_instance = VkInstance {
|
||||||
entry,
|
entry,
|
||||||
instance,
|
instance,
|
||||||
get_phys_dev_props,
|
|
||||||
vk_version,
|
vk_version,
|
||||||
_dbg_loader,
|
_dbg_loader,
|
||||||
_dbg_callbk,
|
_dbg_callbk,
|
||||||
|
@ -271,14 +256,13 @@ impl VkInstance {
|
||||||
choose_compute_device(&self.instance, &devices, surface).ok_or("no suitable device")?;
|
choose_compute_device(&self.instance, &devices, surface).ok_or("no suitable device")?;
|
||||||
|
|
||||||
let mut has_descriptor_indexing = false;
|
let mut has_descriptor_indexing = false;
|
||||||
if let Some(ref get_phys_dev_props) = self.get_phys_dev_props {
|
let vk1_1 = self.vk_version >= vk::make_api_version(0, 1, 1, 0);
|
||||||
|
if vk1_1 {
|
||||||
let mut descriptor_indexing_features =
|
let mut descriptor_indexing_features =
|
||||||
vk::PhysicalDeviceDescriptorIndexingFeatures::builder();
|
vk::PhysicalDeviceDescriptorIndexingFeatures::builder();
|
||||||
// See https://github.com/MaikKlein/ash/issues/325 for why we do this workaround.
|
let mut features_v2 = vk::PhysicalDeviceFeatures2::builder()
|
||||||
let mut features_v2 = vk::PhysicalDeviceFeatures2::default();
|
.push_next(&mut descriptor_indexing_features);
|
||||||
features_v2.p_next =
|
self.instance.get_physical_device_features2(pdevice, &mut features_v2);
|
||||||
&mut descriptor_indexing_features as *mut _ as *mut std::ffi::c_void;
|
|
||||||
get_phys_dev_props.get_physical_device_features2_khr(pdevice, &mut features_v2);
|
|
||||||
has_descriptor_indexing = descriptor_indexing_features
|
has_descriptor_indexing = descriptor_indexing_features
|
||||||
.shader_storage_image_array_non_uniform_indexing
|
.shader_storage_image_array_non_uniform_indexing
|
||||||
== vk::TRUE
|
== vk::TRUE
|
||||||
|
@ -309,9 +293,9 @@ impl VkInstance {
|
||||||
extensions.try_add(vk::KhrMaintenance3Fn::name());
|
extensions.try_add(vk::KhrMaintenance3Fn::name());
|
||||||
extensions.try_add(vk::ExtDescriptorIndexingFn::name());
|
extensions.try_add(vk::ExtDescriptorIndexingFn::name());
|
||||||
}
|
}
|
||||||
let has_subgroup_size = self.vk_version >= vk::make_version(1, 1, 0)
|
let has_subgroup_size = vk1_1
|
||||||
&& extensions.try_add(vk::ExtSubgroupSizeControlFn::name());
|
&& extensions.try_add(vk::ExtSubgroupSizeControlFn::name());
|
||||||
let has_memory_model = self.vk_version >= vk::make_version(1, 1, 0)
|
let has_memory_model = vk1_1
|
||||||
&& extensions.try_add(vk::KhrVulkanMemoryModelFn::name());
|
&& extensions.try_add(vk::KhrVulkanMemoryModelFn::name());
|
||||||
let mut create_info = vk::DeviceCreateInfo::builder()
|
let mut create_info = vk::DeviceCreateInfo::builder()
|
||||||
.queue_create_infos(&queue_create_infos)
|
.queue_create_infos(&queue_create_infos)
|
||||||
|
@ -353,7 +337,7 @@ impl VkInstance {
|
||||||
let use_staging_buffers = props.device_type != vk::PhysicalDeviceType::INTEGRATED_GPU;
|
let use_staging_buffers = props.device_type != vk::PhysicalDeviceType::INTEGRATED_GPU;
|
||||||
|
|
||||||
// TODO: finer grained query of specific subgroup info.
|
// TODO: finer grained query of specific subgroup info.
|
||||||
let has_subgroups = self.vk_version >= vk::make_version(1, 1, 0);
|
let has_subgroups = vk1_1;
|
||||||
|
|
||||||
let workgroup_limits = WorkgroupLimits {
|
let workgroup_limits = WorkgroupLimits {
|
||||||
max_invocations: props.limits.max_compute_work_group_invocations,
|
max_invocations: props.limits.max_compute_work_group_invocations,
|
||||||
|
|
|
@ -172,11 +172,8 @@ impl PietGpuTextLayout {
|
||||||
|
|
||||||
pub(crate) fn draw_text(&self, ctx: &mut PietGpuRenderContext, pos: Point) {
|
pub(crate) fn draw_text(&self, ctx: &mut PietGpuRenderContext, pos: Point) {
|
||||||
let mut scale_ctx = ScaleContext::new();
|
let mut scale_ctx = ScaleContext::new();
|
||||||
let scaler = scale_ctx.builder(self.font.font_ref).size(2048.)
|
let scaler = scale_ctx.builder(self.font.font_ref).size(2048.).build();
|
||||||
.build();
|
let mut tc = TextRenderCtx { scaler };
|
||||||
let mut tc = TextRenderCtx {
|
|
||||||
scaler,
|
|
||||||
};
|
|
||||||
// Should we use ppem from font, or let swash scale?
|
// Should we use ppem from font, or let swash scale?
|
||||||
const DEFAULT_UPEM: u16 = 2048;
|
const DEFAULT_UPEM: u16 = 2048;
|
||||||
let scale = self.size as f32 / DEFAULT_UPEM as f32;
|
let scale = self.size as f32 / DEFAULT_UPEM as f32;
|
||||||
|
|
Loading…
Reference in a new issue