Skip to content

Commit

Permalink
Merge pull request #221 from mahkoh/jorth/ash38
Browse files Browse the repository at this point in the history
vulkan: upgrade to ash 0.38
  • Loading branch information
mahkoh authored Jul 9, 2024
2 parents 831906d + fdc0463 commit 1a0181f
Show file tree
Hide file tree
Showing 17 changed files with 236 additions and 279 deletions.
22 changes: 6 additions & 16 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -51,9 +51,9 @@ chrono = "0.4.33"
parking_lot = "0.12.1"
arrayvec = "0.7.4"
indexmap = "2.2.0"
ash = "0.37.3"
ash = "0.38.0"
gpu-alloc = "0.6.0"
gpu-alloc-ash = "0.6.0"
gpu-alloc-ash = "0.7.0"
serde = { version = "1.0.196", features = ["derive"] }
enum-map = "2.7.3"
png = "0.17.13"
Expand Down
2 changes: 2 additions & 0 deletions deploy-notes.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
# Unreleased

- Needs jay-compositor release.

# 1.4.0

- Needs jay-config release.
Expand Down
4 changes: 2 additions & 2 deletions src/gfx_apis/vulkan/command.rs
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ impl Drop for VulkanCommandBuffer {

impl VulkanCommandPool {
pub fn allocate_buffer(self: &Rc<Self>) -> Result<Rc<VulkanCommandBuffer>, VulkanError> {
let create_info = CommandBufferAllocateInfo::builder()
let create_info = CommandBufferAllocateInfo::default()
.command_pool(self.pool)
.command_buffer_count(1)
.level(CommandBufferLevel::PRIMARY);
Expand All @@ -54,7 +54,7 @@ impl VulkanCommandPool {

impl VulkanDevice {
pub fn create_command_pool(self: &Rc<Self>) -> Result<Rc<VulkanCommandPool>, VulkanError> {
let info = CommandPoolCreateInfo::builder()
let info = CommandPoolCreateInfo::default()
.queue_family_index(self.graphics_queue_idx)
.flags(
CommandPoolCreateFlags::TRANSIENT | CommandPoolCreateFlags::RESET_COMMAND_BUFFER,
Expand Down
7 changes: 3 additions & 4 deletions src/gfx_apis/vulkan/descriptor.rs
Original file line number Diff line number Diff line change
Expand Up @@ -29,13 +29,12 @@ impl VulkanDevice {
sampler: &Rc<VulkanSampler>,
) -> Result<Rc<VulkanDescriptorSetLayout>, VulkanError> {
let immutable_sampler = [sampler.sampler];
let binding = DescriptorSetLayoutBinding::builder()
let binding = DescriptorSetLayoutBinding::default()
.stage_flags(ShaderStageFlags::FRAGMENT)
.immutable_samplers(&immutable_sampler)
.descriptor_count(1)
.descriptor_type(DescriptorType::COMBINED_IMAGE_SAMPLER)
.build();
let create_info = DescriptorSetLayoutCreateInfo::builder()
.descriptor_type(DescriptorType::COMBINED_IMAGE_SAMPLER);
let create_info = DescriptorSetLayoutCreateInfo::default()
.bindings(slice::from_ref(&binding))
.flags(DescriptorSetLayoutCreateFlags::PUSH_DESCRIPTOR_KHR);
let layout = unsafe { self.device.create_descriptor_set_layout(&create_info, None) };
Expand Down
80 changes: 41 additions & 39 deletions src/gfx_apis/vulkan/device.rs
Original file line number Diff line number Diff line change
Expand Up @@ -18,14 +18,18 @@ use {
ahash::AHashMap,
arrayvec::ArrayVec,
ash::{
extensions::khr::{ExternalFenceFd, ExternalMemoryFd, ExternalSemaphoreFd, PushDescriptor},
ext::{
external_memory_dma_buf, image_drm_format_modifier, physical_device_drm,
queue_family_foreign,
},
khr::{
driver_properties, external_fence_fd, external_memory_fd, external_semaphore_fd,
push_descriptor,
},
vk::{
DeviceCreateInfo, DeviceQueueCreateInfo, ExtExternalMemoryDmaBufFn,
ExtImageDrmFormatModifierFn, ExtPhysicalDeviceDrmFn, ExtQueueFamilyForeignFn,
ExternalSemaphoreFeatureFlags, ExternalSemaphoreHandleTypeFlags,
ExternalSemaphoreProperties, KhrDriverPropertiesFn, KhrExternalFenceFdFn,
KhrExternalMemoryFdFn, KhrExternalSemaphoreFdFn, KhrPushDescriptorFn,
MemoryPropertyFlags, MemoryType, PhysicalDevice, PhysicalDeviceDriverProperties,
DeviceCreateInfo, DeviceQueueCreateInfo, ExternalSemaphoreFeatureFlags,
ExternalSemaphoreHandleTypeFlags, ExternalSemaphoreProperties, MemoryPropertyFlags,
MemoryType, PhysicalDevice, PhysicalDeviceDriverProperties,
PhysicalDeviceDriverPropertiesKHR, PhysicalDeviceDrmPropertiesEXT,
PhysicalDeviceDynamicRenderingFeatures, PhysicalDeviceExternalSemaphoreInfo,
PhysicalDeviceProperties, PhysicalDeviceProperties2,
Expand All @@ -49,10 +53,10 @@ pub struct VulkanDevice {
pub(super) sync_ctx: Rc<SyncObjCtx>,
pub(super) instance: Rc<VulkanInstance>,
pub(super) device: Device,
pub(super) external_memory_fd: ExternalMemoryFd,
pub(super) external_semaphore_fd: ExternalSemaphoreFd,
pub(super) external_fence_fd: ExternalFenceFd,
pub(super) push_descriptor: PushDescriptor,
pub(super) external_memory_fd: external_memory_fd::Device,
pub(super) external_semaphore_fd: external_semaphore_fd::Device,
pub(super) external_fence_fd: external_fence_fd::Device,
pub(super) push_descriptor: push_descriptor::Device,
pub(super) formats: AHashMap<u32, VulkanFormat>,
pub(super) memory_types: ArrayVec<MemoryType, MAX_MEMORY_TYPES>,
pub(super) graphics_queue: Queue,
Expand Down Expand Up @@ -129,14 +133,14 @@ impl VulkanInstance {
continue;
}
};
if !extensions.contains_key(ExtPhysicalDeviceDrmFn::name()) {
if !extensions.contains_key(physical_device_drm::NAME) {
devices.push((props, Some(extensions), None));
continue;
}
let has_driver_props = extensions.contains_key(KhrDriverPropertiesFn::name());
let mut drm_props = PhysicalDeviceDrmPropertiesEXT::builder().build();
let mut driver_props = PhysicalDeviceDriverPropertiesKHR::builder().build();
let mut props2 = PhysicalDeviceProperties2::builder().push_next(&mut drm_props);
let has_driver_props = extensions.contains_key(driver_properties::NAME);
let mut drm_props = PhysicalDeviceDrmPropertiesEXT::default();
let mut driver_props = PhysicalDeviceDriverPropertiesKHR::default();
let mut props2 = PhysicalDeviceProperties2::default().push_next(&mut drm_props);
if has_driver_props {
props2 = props2.push_next(&mut driver_props);
}
Expand Down Expand Up @@ -181,10 +185,9 @@ impl VulkanInstance {
}

fn supports_semaphore_import(&self, phy_dev: PhysicalDevice) -> bool {
let mut props = ExternalSemaphoreProperties::builder().build();
let info = PhysicalDeviceExternalSemaphoreInfo::builder()
.handle_type(ExternalSemaphoreHandleTypeFlags::OPAQUE_FD)
.build();
let mut props = ExternalSemaphoreProperties::default();
let info = PhysicalDeviceExternalSemaphoreInfo::default()
.handle_type(ExternalSemaphoreHandleTypeFlags::OPAQUE_FD);
unsafe {
self.instance
.get_physical_device_external_semaphore_properties(phy_dev, &info, &mut props);
Expand Down Expand Up @@ -217,16 +220,15 @@ impl VulkanInstance {
.map(|n| n.as_ptr())
.collect();
let mut semaphore_features =
PhysicalDeviceTimelineSemaphoreFeatures::builder().timeline_semaphore(true);
PhysicalDeviceTimelineSemaphoreFeatures::default().timeline_semaphore(true);
let mut synchronization2_features =
PhysicalDeviceSynchronization2Features::builder().synchronization2(true);
PhysicalDeviceSynchronization2Features::default().synchronization2(true);
let mut dynamic_rendering_features =
PhysicalDeviceDynamicRenderingFeatures::builder().dynamic_rendering(true);
let queue_create_info = DeviceQueueCreateInfo::builder()
PhysicalDeviceDynamicRenderingFeatures::default().dynamic_rendering(true);
let queue_create_info = DeviceQueueCreateInfo::default()
.queue_family_index(graphics_queue_idx)
.queue_priorities(&[1.0])
.build();
let device_create_info = DeviceCreateInfo::builder()
.queue_priorities(&[1.0]);
let device_create_info = DeviceCreateInfo::default()
.push_next(&mut semaphore_features)
.push_next(&mut synchronization2_features)
.push_next(&mut dynamic_rendering_features)
Expand Down Expand Up @@ -258,10 +260,10 @@ impl VulkanInstance {
return Err(VulkanError::XRGB8888);
}
destroy_device.forget();
let external_memory_fd = ExternalMemoryFd::new(&self.instance, &device);
let external_semaphore_fd = ExternalSemaphoreFd::new(&self.instance, &device);
let external_fence_fd = ExternalFenceFd::new(&self.instance, &device);
let push_descriptor = PushDescriptor::new(&self.instance, &device);
let external_memory_fd = external_memory_fd::Device::new(&self.instance, &device);
let external_semaphore_fd = external_semaphore_fd::Device::new(&self.instance, &device);
let external_fence_fd = external_fence_fd::Device::new(&self.instance, &device);
let push_descriptor = push_descriptor::Device::new(&self.instance, &device);
let memory_properties =
unsafe { self.instance.get_physical_device_memory_properties(phy_dev) };
let memory_types = memory_properties.memory_types
Expand Down Expand Up @@ -290,13 +292,13 @@ impl VulkanInstance {
}

const REQUIRED_DEVICE_EXTENSIONS: &[&CStr] = &[
KhrExternalMemoryFdFn::name(),
KhrExternalSemaphoreFdFn::name(),
KhrExternalFenceFdFn::name(),
ExtExternalMemoryDmaBufFn::name(),
ExtQueueFamilyForeignFn::name(),
ExtImageDrmFormatModifierFn::name(),
KhrPushDescriptorFn::name(),
external_memory_fd::NAME,
external_semaphore_fd::NAME,
external_fence_fd::NAME,
external_memory_dma_buf::NAME,
queue_family_foreign::NAME,
image_drm_format_modifier::NAME,
push_descriptor::NAME,
];

fn log_device(
Expand All @@ -322,7 +324,7 @@ fn log_device(
log::warn!(" device does not support vulkan 1.3");
}
if let Some(extensions) = extensions {
if !extensions.contains_key(ExtPhysicalDeviceDrmFn::name()) {
if !extensions.contains_key(physical_device_drm::NAME) {
log::warn!(" device does support not the VK_EXT_physical_device_drm extension");
}
}
Expand Down
6 changes: 3 additions & 3 deletions src/gfx_apis/vulkan/fence.rs
Original file line number Diff line number Diff line change
Expand Up @@ -27,9 +27,9 @@ impl Drop for VulkanFence {
impl VulkanDevice {
pub fn create_fence(self: &Rc<Self>) -> Result<Rc<VulkanFence>, VulkanError> {
let fence = {
let mut export_info = ExportFenceCreateInfo::builder()
let mut export_info = ExportFenceCreateInfo::default()
.handle_types(ExternalFenceHandleTypeFlags::SYNC_FD);
let create_info = FenceCreateInfo::builder().push_next(&mut export_info);
let create_info = FenceCreateInfo::default().push_next(&mut export_info);
let fence = unsafe { self.device.create_fence(&create_info, None) };
fence.map_err(VulkanError::CreateFence)?
};
Expand All @@ -42,7 +42,7 @@ impl VulkanDevice {

impl VulkanFence {
pub fn export_sync_file(&self) -> Result<SyncFile, VulkanError> {
let info = FenceGetFdInfoKHR::builder()
let info = FenceGetFdInfoKHR::default()
.fence(self.fence)
.handle_type(ExternalFenceHandleTypeFlags::SYNC_FD);
let res = unsafe { self.device.external_fence_fd.get_fence_fd(&info) };
Expand Down
Loading

0 comments on commit 1a0181f

Please sign in to comment.