diff --git a/.travis.yml b/.travis.yml index 2bb3256..e9fdd8e 100644 --- a/.travis.yml +++ b/.travis.yml @@ -1,4 +1,5 @@ sudo: false +language: rust rust: - stable diff --git a/Cargo.toml b/Cargo.toml index f2ab380..89ba198 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -7,13 +7,13 @@ authors = ["Dzmitry Malyshau "] name = "portability" crate-type = ["staticlib"] -[dependencies.gfx_core] -#path = "../gfx/src/core" +[dependencies.gfx-hal] +#path = "../gfx/src/hal" git = "https://github.com/kvark/gfx-rs" -branch = "portability" +branch = "portable" -[dependencies.gfx_backend_vulkan] +[dependencies.gfx-backend-vulkan] #path = "../gfx/src/backend/vulkan" git = "https://github.com/kvark/gfx-rs" -branch = "portability" -#features = ["portable"] +branch = "portable" +features = ["portable"] diff --git a/Makefile b/Makefile index 11d66ef..fb6a9ff 100644 --- a/Makefile +++ b/Makefile @@ -8,7 +8,7 @@ LIBRARY=target/debug/libportability.a CC=gcc CFLAGS=-I$(VULKAN_DIR) DEPS= -LDFLAGS=-lpthread -ldl -lm +LDFLAGS=-lpthread -ldl -lm -lX11 .PHONY: all binding run @@ -19,14 +19,14 @@ binding: $(BINDING) $(BINDING): $(VULKAN_DIR)/vulkan/*.h bindgen --no-layout-tests --rustfmt-bindings $(VULKAN_DIR)/vulkan/vulkan.h -o $(BINDING) -$(LIBRARY): src/*.rs +$(LIBRARY): src/*.rs Cargo.toml cargo build mkdir -p target/native $(NATIVE_DIR)/%.o: native/%.c $(DEPS) $(CC) -c -o $@ $< $(CFLAGS) -$(TARGET): $(LIBRARY) $(OBJECTS) +$(TARGET): $(LIBRARY) $(OBJECTS) Makefile $(CC) -o $(TARGET) $(LDFLAGS) $(OBJECTS) $(LIBRARY) run: $(TARGET) diff --git a/src/lib.rs b/src/lib.rs index eb24807..45c154f 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -2,13 +2,13 @@ #![allow(non_camel_case_types)] #![allow(non_upper_case_globals)] -extern crate gfx_core as core; +extern crate gfx_hal as hal; extern crate gfx_backend_vulkan as back; mod handle; use std::{cmp, slice}; -use core::{Adapter, Instance, QueueFamily}; // traits only +use hal::{Instance, PhysicalDevice, QueueFamily}; // traits only use back::Backend as B; use handle::Handle; @@ -459,8 +459,8 @@ pub type VkDeviceSize = u64; pub type VkSampleMask = u32; pub type VkInstance = Handle; -pub type VkPhysicalDevice = Handle<::Adapter>; -pub type VkDevice = Handle>; +pub type VkPhysicalDevice = Handle>; +pub type VkDevice = Handle>; #[repr(C)] #[derive(Debug, Copy, Clone)] @@ -4377,19 +4377,19 @@ pub extern fn vkGetPhysicalDeviceQueueFamilyProperties( let output = unsafe { slice::from_raw_parts_mut(pQueueFamilyProperties, *pQueueFamilyPropertyCount as _) }; - let families = physicalDevice.get_queue_families(); + let families = &physicalDevice.queue_families; if output.len() > families.len() { unsafe { *pQueueFamilyPropertyCount = families.len() as _ }; } - for (ref mut out, &(ref family, ty)) in output.iter_mut().zip(families.iter()) { + for (ref mut out, ref family) in output.iter_mut().zip(families.iter()) { **out = VkQueueFamilyProperties { - queueFlags: match ty { - core::QueueType::General => VkQueueFlagBits::VK_QUEUE_GRAPHICS_BIT as u32 | VkQueueFlagBits::VK_QUEUE_COMPUTE_BIT as u32, - core::QueueType::Graphics => VkQueueFlagBits::VK_QUEUE_GRAPHICS_BIT as u32, - core::QueueType::Compute => VkQueueFlagBits::VK_QUEUE_COMPUTE_BIT as u32, - core::QueueType::Transfer => VkQueueFlagBits::VK_QUEUE_TRANSFER_BIT as u32, + queueFlags: match family.queue_type() { + hal::QueueType::General => VkQueueFlagBits::VK_QUEUE_GRAPHICS_BIT as u32 | VkQueueFlagBits::VK_QUEUE_COMPUTE_BIT as u32, + hal::QueueType::Graphics => VkQueueFlagBits::VK_QUEUE_GRAPHICS_BIT as u32, + hal::QueueType::Compute => VkQueueFlagBits::VK_QUEUE_COMPUTE_BIT as u32, + hal::QueueType::Transfer => VkQueueFlagBits::VK_QUEUE_TRANSFER_BIT as u32, }, - queueCount: family.num_queues(), + queueCount: family.max_queues() as _, timestampValidBits: 0, //TODO minImageTransferGranularity: VkExtent3D { width: 0, height: 0, depth: 0 }, //TODO } @@ -4424,13 +4424,14 @@ pub extern fn vkCreateDevice( let queue_infos = unsafe { slice::from_raw_parts(dev_info.pQueueCreateInfos, dev_info.queueCreateInfoCount as _) }; - let families = physicalDevice.get_queue_families(); let request_infos = queue_infos.iter().map(|info| { - let (ref family, ty) = families[info.queueFamilyIndex as usize]; - (family, ty, info.queueCount) + let family = physicalDevice + .queue_families[info.queueFamilyIndex as usize] + .clone(); + (family, vec![1.0; info.queueCount as usize]) }).collect::>(); - let gpu = physicalDevice.open(&request_infos); + let gpu = physicalDevice.physical_device.clone().open(request_infos); unsafe { *pDevice = Handle::new(gpu) }; VkResult::VK_SUCCESS