Update to latest gfx-rs

This commit is contained in:
Dzmitry Malyshau 2017-11-06 21:57:32 -05:00
parent 101a0521b9
commit 1828304cbd
4 changed files with 27 additions and 25 deletions

View file

@ -1,4 +1,5 @@
sudo: false sudo: false
language: rust
rust: rust:
- stable - stable

View file

@ -7,13 +7,13 @@ authors = ["Dzmitry Malyshau <kvark@mozilla.com>"]
name = "portability" name = "portability"
crate-type = ["staticlib"] crate-type = ["staticlib"]
[dependencies.gfx_core] [dependencies.gfx-hal]
#path = "../gfx/src/core" #path = "../gfx/src/hal"
git = "https://github.com/kvark/gfx-rs" git = "https://github.com/kvark/gfx-rs"
branch = "portability" branch = "portable"
[dependencies.gfx_backend_vulkan] [dependencies.gfx-backend-vulkan]
#path = "../gfx/src/backend/vulkan" #path = "../gfx/src/backend/vulkan"
git = "https://github.com/kvark/gfx-rs" git = "https://github.com/kvark/gfx-rs"
branch = "portability" branch = "portable"
#features = ["portable"] features = ["portable"]

View file

@ -8,7 +8,7 @@ LIBRARY=target/debug/libportability.a
CC=gcc CC=gcc
CFLAGS=-I$(VULKAN_DIR) CFLAGS=-I$(VULKAN_DIR)
DEPS= DEPS=
LDFLAGS=-lpthread -ldl -lm LDFLAGS=-lpthread -ldl -lm -lX11
.PHONY: all binding run .PHONY: all binding run
@ -19,14 +19,14 @@ binding: $(BINDING)
$(BINDING): $(VULKAN_DIR)/vulkan/*.h $(BINDING): $(VULKAN_DIR)/vulkan/*.h
bindgen --no-layout-tests --rustfmt-bindings $(VULKAN_DIR)/vulkan/vulkan.h -o $(BINDING) bindgen --no-layout-tests --rustfmt-bindings $(VULKAN_DIR)/vulkan/vulkan.h -o $(BINDING)
$(LIBRARY): src/*.rs $(LIBRARY): src/*.rs Cargo.toml
cargo build cargo build
mkdir -p target/native mkdir -p target/native
$(NATIVE_DIR)/%.o: native/%.c $(DEPS) $(NATIVE_DIR)/%.o: native/%.c $(DEPS)
$(CC) -c -o $@ $< $(CFLAGS) $(CC) -c -o $@ $< $(CFLAGS)
$(TARGET): $(LIBRARY) $(OBJECTS) $(TARGET): $(LIBRARY) $(OBJECTS) Makefile
$(CC) -o $(TARGET) $(LDFLAGS) $(OBJECTS) $(LIBRARY) $(CC) -o $(TARGET) $(LDFLAGS) $(OBJECTS) $(LIBRARY)
run: $(TARGET) run: $(TARGET)

View file

@ -2,13 +2,13 @@
#![allow(non_camel_case_types)] #![allow(non_camel_case_types)]
#![allow(non_upper_case_globals)] #![allow(non_upper_case_globals)]
extern crate gfx_core as core; extern crate gfx_hal as hal;
extern crate gfx_backend_vulkan as back; extern crate gfx_backend_vulkan as back;
mod handle; mod handle;
use std::{cmp, slice}; use std::{cmp, slice};
use core::{Adapter, Instance, QueueFamily}; // traits only use hal::{Instance, PhysicalDevice, QueueFamily}; // traits only
use back::Backend as B; use back::Backend as B;
use handle::Handle; use handle::Handle;
@ -459,8 +459,8 @@ pub type VkDeviceSize = u64;
pub type VkSampleMask = u32; pub type VkSampleMask = u32;
pub type VkInstance = Handle<back::Instance>; pub type VkInstance = Handle<back::Instance>;
pub type VkPhysicalDevice = Handle<<B as core::Backend>::Adapter>; pub type VkPhysicalDevice = Handle<hal::Adapter<B>>;
pub type VkDevice = Handle<core::Gpu<B>>; pub type VkDevice = Handle<hal::Gpu<B>>;
#[repr(C)] #[repr(C)]
#[derive(Debug, Copy, Clone)] #[derive(Debug, Copy, Clone)]
@ -4377,19 +4377,19 @@ pub extern fn vkGetPhysicalDeviceQueueFamilyProperties(
let output = unsafe { let output = unsafe {
slice::from_raw_parts_mut(pQueueFamilyProperties, *pQueueFamilyPropertyCount as _) slice::from_raw_parts_mut(pQueueFamilyProperties, *pQueueFamilyPropertyCount as _)
}; };
let families = physicalDevice.get_queue_families(); let families = &physicalDevice.queue_families;
if output.len() > families.len() { if output.len() > families.len() {
unsafe { *pQueueFamilyPropertyCount = families.len() as _ }; 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 { **out = VkQueueFamilyProperties {
queueFlags: match ty { queueFlags: match family.queue_type() {
core::QueueType::General => VkQueueFlagBits::VK_QUEUE_GRAPHICS_BIT as u32 | VkQueueFlagBits::VK_QUEUE_COMPUTE_BIT as u32, hal::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, hal::QueueType::Graphics => VkQueueFlagBits::VK_QUEUE_GRAPHICS_BIT as u32,
core::QueueType::Compute => VkQueueFlagBits::VK_QUEUE_COMPUTE_BIT as u32, hal::QueueType::Compute => VkQueueFlagBits::VK_QUEUE_COMPUTE_BIT as u32,
core::QueueType::Transfer => VkQueueFlagBits::VK_QUEUE_TRANSFER_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 timestampValidBits: 0, //TODO
minImageTransferGranularity: VkExtent3D { width: 0, height: 0, depth: 0 }, //TODO minImageTransferGranularity: VkExtent3D { width: 0, height: 0, depth: 0 }, //TODO
} }
@ -4424,13 +4424,14 @@ pub extern fn vkCreateDevice(
let queue_infos = unsafe { let queue_infos = unsafe {
slice::from_raw_parts(dev_info.pQueueCreateInfos, dev_info.queueCreateInfoCount as _) 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 request_infos = queue_infos.iter().map(|info| {
let (ref family, ty) = families[info.queueFamilyIndex as usize]; let family = physicalDevice
(family, ty, info.queueCount) .queue_families[info.queueFamilyIndex as usize]
.clone();
(family, vec![1.0; info.queueCount as usize])
}).collect::<Vec<_>>(); }).collect::<Vec<_>>();
let gpu = physicalDevice.open(&request_infos); let gpu = physicalDevice.physical_device.clone().open(request_infos);
unsafe { *pDevice = Handle::new(gpu) }; unsafe { *pDevice = Handle::new(gpu) };
VkResult::VK_SUCCESS VkResult::VK_SUCCESS