From 414ae9d59616cae572d2e1ec7a62cffbfc01107c Mon Sep 17 00:00:00 2001 From: Dzmitry Malyshau Date: Sun, 14 Mar 2021 00:17:06 -0500 Subject: [PATCH] Update to latest gfx with new limits --- Cargo.lock | 102 ++++++++++++++++++++++++-------- libportability-gfx/src/conv.rs | 37 +++++------- libportability-gfx/src/impls.rs | 10 ++-- 3 files changed, 100 insertions(+), 49 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 0945740..ea5c279 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -27,7 +27,7 @@ version = "0.31.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "c69a8137596e84c22d57f3da1b5de1d4230b1742a710091c85f4d7ce50f00f38" dependencies = [ - "libloading", + "libloading 0.6.5", ] [[package]] @@ -222,11 +222,10 @@ dependencies = [ [[package]] name = "d3d12" version = "0.3.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d0a60cceb22c7c53035f8980524fdc7f17cf49681a3c154e6757d30afbec6ec4" +source = "git+https://github.com/gfx-rs/d3d12-rs?rev=be19a243b86e0bafb9937d661fc8eabb3e42b44e#be19a243b86e0bafb9937d661fc8eabb3e42b44e" dependencies = [ "bitflags", - "libloading", + "libloading 0.7.0", "winapi", ] @@ -236,7 +235,7 @@ version = "0.4.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "b11f15d1e3268f140f68d390637d5e76d849782d971ae7063e0da69fe9709a76" dependencies = [ - "libloading", + "libloading 0.6.5", ] [[package]] @@ -252,6 +251,12 @@ dependencies = [ "termcolor", ] +[[package]] +name = "fixedbitset" +version = "0.2.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "37ab347416e802de484e4d03c7316c48f1ecb56574dfd4a46a80f173ce1de04d" + [[package]] name = "foreign-types" version = "0.3.2" @@ -290,7 +295,7 @@ dependencies = [ [[package]] name = "gfx-auxil" version = "0.8.0" -source = "git+https://github.com/gfx-rs/gfx#dd034e6cc94c175195137c12bd35d5fa98f51dba" +source = "git+https://github.com/gfx-rs/gfx#a8db9a81097d33308c3cc34b0c8c3c0ff5c072cf" dependencies = [ "fxhash", "gfx-hal", @@ -300,13 +305,13 @@ dependencies = [ [[package]] name = "gfx-backend-dx11" version = "0.7.0" -source = "git+https://github.com/gfx-rs/gfx#dd034e6cc94c175195137c12bd35d5fa98f51dba" +source = "git+https://github.com/gfx-rs/gfx#a8db9a81097d33308c3cc34b0c8c3c0ff5c072cf" dependencies = [ "arrayvec", "bitflags", "gfx-auxil", "gfx-hal", - "libloading", + "libloading 0.7.0", "log", "parking_lot", "range-alloc", @@ -321,7 +326,7 @@ dependencies = [ [[package]] name = "gfx-backend-dx12" version = "0.7.0" -source = "git+https://github.com/gfx-rs/gfx#dd034e6cc94c175195137c12bd35d5fa98f51dba" +source = "git+https://github.com/gfx-rs/gfx#a8db9a81097d33308c3cc34b0c8c3c0ff5c072cf" dependencies = [ "arrayvec", "bit-set", @@ -335,13 +340,14 @@ dependencies = [ "raw-window-handle", "smallvec", "spirv_cross", + "thunderdome", "winapi", ] [[package]] name = "gfx-backend-empty" version = "0.7.0" -source = "git+https://github.com/gfx-rs/gfx#dd034e6cc94c175195137c12bd35d5fa98f51dba" +source = "git+https://github.com/gfx-rs/gfx#a8db9a81097d33308c3cc34b0c8c3c0ff5c072cf" dependencies = [ "gfx-hal", "log", @@ -351,20 +357,20 @@ dependencies = [ [[package]] name = "gfx-backend-gl" version = "0.7.0" -source = "git+https://github.com/gfx-rs/gfx#dd034e6cc94c175195137c12bd35d5fa98f51dba" +source = "git+https://github.com/gfx-rs/gfx#a8db9a81097d33308c3cc34b0c8c3c0ff5c072cf" dependencies = [ "arrayvec", "bitflags", - "gfx-auxil", + "fxhash", "gfx-hal", "glow", "js-sys", "khronos-egl", - "libloading", + "libloading 0.7.0", "log", + "naga", "parking_lot", "raw-window-handle", - "spirv_cross", "wasm-bindgen", "web-sys", ] @@ -372,7 +378,7 @@ dependencies = [ [[package]] name = "gfx-backend-metal" version = "0.7.0" -source = "git+https://github.com/gfx-rs/gfx#dd034e6cc94c175195137c12bd35d5fa98f51dba" +source = "git+https://github.com/gfx-rs/gfx#a8db9a81097d33308c3cc34b0c8c3c0ff5c072cf" dependencies = [ "arrayvec", "bitflags", @@ -380,22 +386,22 @@ dependencies = [ "cocoa-foundation", "copyless", "foreign-types", - "gfx-auxil", + "fxhash", "gfx-hal", "log", "metal", + "naga", "objc", "parking_lot", "range-alloc", "raw-window-handle", - "spirv_cross", "storage-map", ] [[package]] name = "gfx-backend-vulkan" version = "0.7.0" -source = "git+https://github.com/gfx-rs/gfx#dd034e6cc94c175195137c12bd35d5fa98f51dba" +source = "git+https://github.com/gfx-rs/gfx#a8db9a81097d33308c3cc34b0c8c3c0ff5c072cf" dependencies = [ "arrayvec", "ash", @@ -414,7 +420,7 @@ dependencies = [ [[package]] name = "gfx-hal" version = "0.7.0" -source = "git+https://github.com/gfx-rs/gfx#dd034e6cc94c175195137c12bd35d5fa98f51dba" +source = "git+https://github.com/gfx-rs/gfx#a8db9a81097d33308c3cc34b0c8c3c0ff5c072cf" dependencies = [ "bitflags", "naga", @@ -488,6 +494,12 @@ dependencies = [ "x11-dl", ] +[[package]] +name = "hashbrown" +version = "0.9.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d7afe4a420e3fe79967a00898cc1f4db7c8a49a9333a29f8a4bd76a253d5cd04" + [[package]] name = "hermit-abi" version = "0.1.17" @@ -503,6 +515,16 @@ version = "2.1.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "9a3a5bfb195931eeb336b2a7b4d761daec841b97f947d34394601737a7bba5e4" +[[package]] +name = "indexmap" +version = "1.6.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "824845a0bf897a9042383849b02c1bc219c2383772efcd5c6f9766fa4b81aef3" +dependencies = [ + "autocfg", + "hashbrown", +] + [[package]] name = "inplace_it" version = "0.3.3" @@ -538,12 +560,12 @@ dependencies = [ [[package]] name = "khronos-egl" -version = "3.0.0" +version = "4.0.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a8020ff3b84f9ac87461216ad0501bc09b33c1cbe17404d8ea405160fd164bab" +checksum = "7e8cc4d128654d2191681ab98140c4d99e4bd9333efe1526e033586a5a061e1e" dependencies = [ "libc", - "libloading", + "libloading 0.7.0", ] [[package]] @@ -586,6 +608,16 @@ dependencies = [ "winapi", ] +[[package]] +name = "libloading" +version = "0.7.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6f84d96438c15fcd6c3f244c8fce01d1e2b9c6b5623e9c711dc9286d8fc92d6a" +dependencies = [ + "cfg-if 1.0.0", + "winapi", +] + [[package]] name = "lock_api" version = "0.4.1" @@ -651,13 +683,15 @@ dependencies = [ [[package]] name = "naga" version = "0.3.1" -source = "git+https://github.com/gfx-rs/naga?tag=gfx-9#c12003f5648fcade5f20c01debc4cb12bd47073e" +source = "git+https://github.com/gfx-rs/naga?tag=gfx-15#196523de7820d4907a14bd22517c4d572d26b0be" dependencies = [ "bit-set", "bitflags", "fxhash", "log", "num-traits", + "petgraph", + "spirv_headers", "thiserror", ] @@ -730,6 +764,16 @@ version = "1.0.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "31010dd2e1ac33d5b46a5b413495239882813e0369f8ed8a5e266f173602f831" +[[package]] +name = "petgraph" +version = "0.5.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "467d164a6de56270bd7c4d070df81d07beace25012d5103ced4e9ff08d6afdb7" +dependencies = [ + "fixedbitset", + "indexmap", +] + [[package]] name = "pkg-config" version = "0.3.19" @@ -837,7 +881,7 @@ dependencies = [ [[package]] name = "range-alloc" version = "0.1.2" -source = "git+https://github.com/gfx-rs/gfx#dd034e6cc94c175195137c12bd35d5fa98f51dba" +source = "git+https://github.com/gfx-rs/gfx#a8db9a81097d33308c3cc34b0c8c3c0ff5c072cf" [[package]] name = "raw-window-handle" @@ -934,6 +978,16 @@ dependencies = [ "wasm-bindgen", ] +[[package]] +name = "spirv_headers" +version = "1.5.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1f5b132530b1ac069df335577e3581765995cba5a13995cdbbdbc8fb057c532c" +dependencies = [ + "bitflags", + "num-traits", +] + [[package]] name = "storage-map" version = "0.3.0" diff --git a/libportability-gfx/src/conv.rs b/libportability-gfx/src/conv.rs index a94d658..1847269 100644 --- a/libportability-gfx/src/conv.rs +++ b/libportability-gfx/src/conv.rs @@ -9,6 +9,7 @@ use super::*; pub fn limits_from_hal(limits: Limits) -> VkPhysicalDeviceLimits { let viewport_size = limits.max_viewport_dimensions[0].max(limits.max_viewport_dimensions[1]); + let dl = limits.descriptor_limits; VkPhysicalDeviceLimits { maxImageDimension1D: limits.max_image_1d_size, maxImageDimension2D: limits.max_image_2d_size, @@ -24,26 +25,21 @@ pub fn limits_from_hal(limits: Limits) -> VkPhysicalDeviceLimits { bufferImageGranularity: limits.buffer_image_granularity, sparseAddressSpaceSize: 0, maxBoundDescriptorSets: limits.max_bound_descriptor_sets as _, - maxPerStageDescriptorSamplers: limits.max_per_stage_descriptor_samplers as _, - maxPerStageDescriptorUniformBuffers: limits.max_per_stage_descriptor_uniform_buffers as _, - maxPerStageDescriptorStorageBuffers: limits.max_per_stage_descriptor_storage_buffers as _, - maxPerStageDescriptorSampledImages: limits.max_per_stage_descriptor_sampled_images as _, - maxPerStageDescriptorStorageImages: limits.max_per_stage_descriptor_storage_images as _, - maxPerStageDescriptorInputAttachments: limits.max_per_stage_descriptor_input_attachments - as _, - maxPerStageResources: limits.max_per_stage_resources as _, - maxDescriptorSetSamplers: limits.max_descriptor_set_samplers as _, - maxDescriptorSetUniformBuffers: limits.max_descriptor_set_uniform_buffers as _, - maxDescriptorSetUniformBuffersDynamic: limits - .max_descriptor_set_uniform_buffers_dynamic - .max(1) as _, - maxDescriptorSetStorageBuffers: limits.max_descriptor_set_storage_buffers as _, - maxDescriptorSetStorageBuffersDynamic: limits - .max_descriptor_set_storage_buffers_dynamic - .max(1) as _, - maxDescriptorSetSampledImages: limits.max_descriptor_set_sampled_images as _, - maxDescriptorSetStorageImages: limits.max_descriptor_set_storage_images as _, - maxDescriptorSetInputAttachments: limits.max_descriptor_set_input_attachments as _, + maxPerStageDescriptorSamplers: dl.max_per_stage_descriptor_samplers, + maxPerStageDescriptorUniformBuffers: dl.max_per_stage_descriptor_uniform_buffers, + maxPerStageDescriptorStorageBuffers: dl.max_per_stage_descriptor_storage_buffers, + maxPerStageDescriptorSampledImages: dl.max_per_stage_descriptor_sampled_images, + maxPerStageDescriptorStorageImages: dl.max_per_stage_descriptor_storage_images, + maxPerStageDescriptorInputAttachments: dl.max_per_stage_descriptor_input_attachments, + maxPerStageResources: dl.max_per_stage_resources, + maxDescriptorSetSamplers: dl.max_descriptor_set_samplers, + maxDescriptorSetUniformBuffers: dl.max_descriptor_set_uniform_buffers, + maxDescriptorSetUniformBuffersDynamic: dl.max_descriptor_set_uniform_buffers_dynamic.max(1), + maxDescriptorSetStorageBuffers: dl.max_descriptor_set_storage_buffers, + maxDescriptorSetStorageBuffersDynamic: dl.max_descriptor_set_storage_buffers_dynamic.max(1), + maxDescriptorSetSampledImages: dl.max_descriptor_set_sampled_images, + maxDescriptorSetStorageImages: dl.max_descriptor_set_storage_images, + maxDescriptorSetInputAttachments: dl.max_descriptor_set_input_attachments, maxVertexInputAttributes: limits.max_vertex_input_attributes as _, maxVertexInputBindings: limits.max_vertex_input_bindings as _, maxVertexInputAttributeOffset: limits.max_vertex_input_attribute_offset as _, @@ -689,7 +685,6 @@ pub fn map_err_device_creation(err: device::CreationError) -> VkResult { device::CreationError::OutOfMemory(Host) => VkResult::VK_ERROR_OUT_OF_HOST_MEMORY, device::CreationError::OutOfMemory(Device) => VkResult::VK_ERROR_OUT_OF_DEVICE_MEMORY, device::CreationError::InitializationFailed => VkResult::VK_ERROR_INITIALIZATION_FAILED, - device::CreationError::MissingExtension => VkResult::VK_ERROR_EXTENSION_NOT_PRESENT, device::CreationError::MissingFeature => VkResult::VK_ERROR_FEATURE_NOT_PRESENT, device::CreationError::TooManyObjects => VkResult::VK_ERROR_TOO_MANY_OBJECTS, device::CreationError::DeviceLost => VkResult::VK_ERROR_DEVICE_LOST, diff --git a/libportability-gfx/src/impls.rs b/libportability-gfx/src/impls.rs index 16ecfd8..3f2de6f 100644 --- a/libportability-gfx/src/impls.rs +++ b/libportability-gfx/src/impls.rs @@ -434,7 +434,7 @@ pub unsafe extern "C" fn gfxGetPhysicalDeviceProperties( pProperties: *mut VkPhysicalDeviceProperties, ) { let adapter_info = &adapter.info; - let limits = conv::limits_from_hal(adapter.physical_device.limits()); + let limits = conv::limits_from_hal(adapter.physical_device.properties().limits); let sparse_properties = mem::zeroed(); // TODO let (major, minor, patch) = VERSION; @@ -487,7 +487,7 @@ pub unsafe extern "C" fn gfxGetPhysicalDeviceProperties2KHR( let data = (ptr as *mut VkPhysicalDevicePortabilitySubsetPropertiesKHR).as_mut().unwrap() ; - let limits = adapter.physical_device.limits(); + let limits = adapter.physical_device.properties().limits; data.minVertexInputBindingStrideAlignment = limits.min_vertex_input_binding_stride_alignment as u32; data.pNext } @@ -1721,11 +1721,11 @@ pub unsafe extern "C" fn gfxCreateBuffer( ) -> VkResult { let info = &*pCreateInfo; assert_eq!(info.sharingMode, VkSharingMode::VK_SHARING_MODE_EXCLUSIVE); // TODO - assert_eq!(info.flags, 0); // TODO + let sparse_flags = hal::memory::SparseFlags::from_bits_truncate(info.flags); let buffer = gpu .device - .create_buffer(info.size, conv::map_buffer_usage(info.usage)) + .create_buffer(info.size, conv::map_buffer_usage(info.usage), sparse_flags) .expect("Error on creating buffer"); *pBuffer = Handle::new(buffer); VkResult::VK_SUCCESS @@ -1795,6 +1795,7 @@ pub unsafe extern "C" fn gfxCreateImage( warn!("unexpected initial layout: {:?}", info.initialLayout); } + let sparse_flags = hal::memory::SparseFlags::from_bits_truncate(info.flags); let kind = conv::map_image_kind( info.imageType, info.extent, @@ -1819,6 +1820,7 @@ pub unsafe extern "C" fn gfxCreateImage( format, conv::map_tiling(info.tiling), usage, + sparse_flags, view_caps, ) .expect("Error on creating image");