mirror of
https://github.com/italicsjenga/portability.git
synced 2024-11-22 15:01:31 +11:00
Update to latest gfx-rs
This commit is contained in:
parent
101a0521b9
commit
1828304cbd
|
@ -1,4 +1,5 @@
|
|||
sudo: false
|
||||
language: rust
|
||||
|
||||
rust:
|
||||
- stable
|
||||
|
|
12
Cargo.toml
12
Cargo.toml
|
@ -7,13 +7,13 @@ authors = ["Dzmitry Malyshau <kvark@mozilla.com>"]
|
|||
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"]
|
||||
|
|
6
Makefile
6
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)
|
||||
|
|
33
src/lib.rs
33
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<back::Instance>;
|
||||
pub type VkPhysicalDevice = Handle<<B as core::Backend>::Adapter>;
|
||||
pub type VkDevice = Handle<core::Gpu<B>>;
|
||||
pub type VkPhysicalDevice = Handle<hal::Adapter<B>>;
|
||||
pub type VkDevice = Handle<hal::Gpu<B>>;
|
||||
|
||||
#[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::<Vec<_>>();
|
||||
|
||||
let gpu = physicalDevice.open(&request_infos);
|
||||
let gpu = physicalDevice.physical_device.clone().open(request_infos);
|
||||
unsafe { *pDevice = Handle::new(gpu) };
|
||||
|
||||
VkResult::VK_SUCCESS
|
||||
|
|
Loading…
Reference in a new issue