97: Query pools, swapchains, and dota r=grovesNL a=kvark



Co-authored-by: Dzmitry Malyshau <kvarkus@gmail.com>
This commit is contained in:
bors[bot] 2018-06-12 19:02:06 +00:00
commit 488e1028c3
5 changed files with 71 additions and 39 deletions

1
.lldbinit Normal file
View file

@ -0,0 +1 @@
env LD_LIBRARY_PATH=target/debug

20
Cargo.lock generated
View file

@ -252,7 +252,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
[[package]]
name = "gfx-backend-dx12"
version = "0.1.0"
source = "git+https://github.com/gfx-rs/gfx#3e027070fabcebb38d780e261a1c21239ad06316"
source = "git+https://github.com/gfx-rs/gfx#63826ab79f8339436f1e1b26b0e99f72d4274b67"
dependencies = [
"bitflags 1.0.3 (registry+https://github.com/rust-lang/crates.io-index)",
"derivative 1.0.0 (registry+https://github.com/rust-lang/crates.io-index)",
@ -268,7 +268,7 @@ dependencies = [
[[package]]
name = "gfx-backend-metal"
version = "0.1.0"
source = "git+https://github.com/gfx-rs/gfx#3e027070fabcebb38d780e261a1c21239ad06316"
source = "git+https://github.com/gfx-rs/gfx#63826ab79f8339436f1e1b26b0e99f72d4274b67"
dependencies = [
"bitflags 1.0.3 (registry+https://github.com/rust-lang/crates.io-index)",
"block 0.1.6 (registry+https://github.com/rust-lang/crates.io-index)",
@ -280,7 +280,7 @@ dependencies = [
"gfx-hal 0.1.0 (git+https://github.com/gfx-rs/gfx)",
"io-surface 0.10.0 (registry+https://github.com/rust-lang/crates.io-index)",
"log 0.4.2 (registry+https://github.com/rust-lang/crates.io-index)",
"metal-rs 0.10.1 (registry+https://github.com/rust-lang/crates.io-index)",
"metal-rs 0.10.2 (registry+https://github.com/rust-lang/crates.io-index)",
"objc 0.2.2 (registry+https://github.com/rust-lang/crates.io-index)",
"smallvec 0.6.1 (registry+https://github.com/rust-lang/crates.io-index)",
"spirv_cross 0.9.2 (registry+https://github.com/rust-lang/crates.io-index)",
@ -290,7 +290,7 @@ dependencies = [
[[package]]
name = "gfx-backend-vulkan"
version = "0.1.0"
source = "git+https://github.com/gfx-rs/gfx#3e027070fabcebb38d780e261a1c21239ad06316"
source = "git+https://github.com/gfx-rs/gfx#63826ab79f8339436f1e1b26b0e99f72d4274b67"
dependencies = [
"ash 0.24.3 (registry+https://github.com/rust-lang/crates.io-index)",
"byteorder 1.2.3 (registry+https://github.com/rust-lang/crates.io-index)",
@ -308,7 +308,7 @@ dependencies = [
[[package]]
name = "gfx-hal"
version = "0.1.0"
source = "git+https://github.com/gfx-rs/gfx#3e027070fabcebb38d780e261a1c21239ad06316"
source = "git+https://github.com/gfx-rs/gfx#63826ab79f8339436f1e1b26b0e99f72d4274b67"
dependencies = [
"bitflags 1.0.3 (registry+https://github.com/rust-lang/crates.io-index)",
"failure 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)",
@ -468,7 +468,7 @@ dependencies = [
[[package]]
name = "metal-rs"
version = "0.10.1"
version = "0.10.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
dependencies = [
"bitflags 1.0.3 (registry+https://github.com/rust-lang/crates.io-index)",
@ -603,14 +603,14 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
dependencies = [
"aho-corasick 0.6.4 (registry+https://github.com/rust-lang/crates.io-index)",
"memchr 2.0.1 (registry+https://github.com/rust-lang/crates.io-index)",
"regex-syntax 0.6.0 (registry+https://github.com/rust-lang/crates.io-index)",
"regex-syntax 0.6.1 (registry+https://github.com/rust-lang/crates.io-index)",
"thread_local 0.3.5 (registry+https://github.com/rust-lang/crates.io-index)",
"utf8-ranges 1.0.0 (registry+https://github.com/rust-lang/crates.io-index)",
]
[[package]]
name = "regex-syntax"
version = "0.6.0"
version = "0.6.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
dependencies = [
"ucd-util 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)",
@ -989,7 +989,7 @@ dependencies = [
"checksum malloc_buf 0.0.6 (registry+https://github.com/rust-lang/crates.io-index)" = "62bb907fe88d54d8d9ce32a3cceab4218ed2f6b7d35617cafe9adf84e43919cb"
"checksum memchr 2.0.1 (registry+https://github.com/rust-lang/crates.io-index)" = "796fba70e76612589ed2ce7f45282f5af869e0fdd7cc6199fa1aa1f1d591ba9d"
"checksum memmap 0.6.2 (registry+https://github.com/rust-lang/crates.io-index)" = "e2ffa2c986de11a9df78620c01eeaaf27d94d3ff02bf81bfcca953102dd0c6ff"
"checksum metal-rs 0.10.1 (registry+https://github.com/rust-lang/crates.io-index)" = "3ac2894f1ea30a8bac947c43f9f28a500564bf454857dc65e48821eb9d24c680"
"checksum metal-rs 0.10.2 (registry+https://github.com/rust-lang/crates.io-index)" = "535825adbfb4b6c15d7caef76afb241830d2b99079d92699710cb0001513924f"
"checksum objc 0.2.2 (registry+https://github.com/rust-lang/crates.io-index)" = "877f30f37acef6749b1841cceab289707f211aecfc756553cd63976190e6cc2e"
"checksum objc-foundation 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)" = "1add1b659e36c9607c7aab864a76c7a4c2760cd0cd2e120f3fb8b952c7e22bf9"
"checksum objc_exception 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)" = "098cd29a2fa3c230d3463ae069cecccc3fdfd64c0d2496ab5b96f82dab6a00dc"
@ -1003,7 +1003,7 @@ dependencies = [
"checksum redox_syscall 0.1.40 (registry+https://github.com/rust-lang/crates.io-index)" = "c214e91d3ecf43e9a4e41e578973adeb14b474f2bee858742d127af75a0112b1"
"checksum redox_termios 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)" = "7e891cfe48e9100a70a3b6eb652fef28920c117d366339687bd5576160db0f76"
"checksum regex 1.0.0 (registry+https://github.com/rust-lang/crates.io-index)" = "75ecf88252dce580404a22444fc7d626c01815debba56a7f4f536772a5ff19d3"
"checksum regex-syntax 0.6.0 (registry+https://github.com/rust-lang/crates.io-index)" = "8f1ac0f60d675cc6cf13a20ec076568254472551051ad5dd050364d70671bf6b"
"checksum regex-syntax 0.6.1 (registry+https://github.com/rust-lang/crates.io-index)" = "05b06a75f5217880fc5e905952a42750bf44787e56a6c6d6852ed0992f5e1d54"
"checksum remove_dir_all 0.5.1 (registry+https://github.com/rust-lang/crates.io-index)" = "3488ba1b9a2084d38645c4c08276a1752dcbf2c7130d74f1569681ad5d2799c5"
"checksum renderdoc 0.3.0 (registry+https://github.com/rust-lang/crates.io-index)" = "3aee9badfb4078c375d2d0479ed29c9c057b51ade78f94792ba2dcb11f343e7e"
"checksum rustc-demangle 0.1.8 (registry+https://github.com/rust-lang/crates.io-index)" = "76d7ba1feafada44f2d38eed812bd2489a03c0f5abb975799251518b68848649"

View file

@ -10,6 +10,8 @@ TEST_LIST=$(CURDIR)/conformance/deqp.txt
TEST_LIST_SOURCE=$(CTS_DIR)/external/vulkancts/mustpass/1.0.2/vk-default.txt
DEQP_DIR=$(CTS_DIR)/build/external/vulkancts/modules/vulkan/
DEQP=cd $(DEQP_DIR) && RUST_LOG=debug LD_LIBRARY_PATH=$(FULL_LIBRARY_PATH) ./deqp-vk
DOTA_DIR=../dota2/bin/osx64
DOTA_EXE=$(DOTA_DIR)/dota2.app/Contents/MacOS/dota2
RUST_BACKTRACE:=1
BACKEND:=gl
@ -43,7 +45,7 @@ FULL_LIBRARY_PATH=$(CURDIR)/target/debug
LIBRARY=target/debug/libportability.$(LIB_EXTENSION)
LIBRARY_FAST=target/release/libportability.$(LIB_EXTENSION)
.PHONY: all rebuild debug debug-version release binding run cts clean cherry
.PHONY: all rebuild debug release debug-version release-version binding run cts clean cherry dota-debug dota-release
all: $(TARGET)
@ -51,13 +53,22 @@ rebuild:
cargo build --manifest-path libportability/Cargo.toml --features $(BACKEND)
debug:
cargo build --manifest-path libportability/Cargo.toml --features "$(BACKEND) debug"
debug-version:
cargo rustc --manifest-path libportability/Cargo.toml --features "$(BACKEND) debug" -- -Clink-arg="-current_version 1.0.0" -Clink-arg="-compatibility_version 1.0.0"
cargo build --manifest-path libportability/Cargo.toml --features $(BACKEND),debug
release: $(LIBRARY_FAST)
debug-version:
cargo rustc --manifest-path libportability/Cargo.toml --features $(BACKEND),portability-gfx/env_logger -- -Clink-arg="-current_version 1.0.0" -Clink-arg="-compatibility_version 1.0.0"
release-version:
cargo rustc --release --manifest-path libportability/Cargo.toml --features $(BACKEND) -- -Clink-arg="-current_version 1.0.0" -Clink-arg="-compatibility_version 1.0.0"
dota-debug: debug-version
DYLD_LIBRARY_PATH=`pwd`/target/debug:`pwd`/$(DOTA_DIR) $(DOTA_EXE)
dota-release: release-version
DYLD_LIBRARY_PATH=`pwd`/target/release:`pwd`/$(DOTA_DIR) $(DOTA_EXE)
binding: $(BINDING)
$(BINDING): $(VULKAN_DIR)/vulkan/*.h

View file

@ -132,6 +132,13 @@ pub fn extent2d_from_hal(extent: window::Extent2D) -> VkExtent2D {
}
}
pub fn map_extent2d(extent: VkExtent2D) -> window::Extent2D {
window::Extent2D {
width: extent.width,
height: extent.height,
}
}
pub fn extent3d_from_hal(extent: image::Extent) -> VkExtent3D {
VkExtent3D {
width: extent.width,

View file

@ -1178,9 +1178,10 @@ pub extern "C" fn gfxCreateQueryPool(
_gpu: VkDevice,
_pCreateInfo: *const VkQueryPoolCreateInfo,
_pAllocator: *const VkAllocationCallbacks,
_pQueryPool: *mut VkQueryPool,
pQueryPool: *mut VkQueryPool,
) -> VkResult {
//TODO
unsafe { *pQueryPool = ptr::null_mut() };
VkResult::VK_ERROR_DEVICE_LOST
}
#[inline]
@ -1199,12 +1200,19 @@ pub extern "C" fn gfxGetQueryPoolResults(
_queryPool: VkQueryPool,
_firstQuery: u32,
_queryCount: u32,
_dataSize: usize,
_pData: *mut ::std::os::raw::c_void,
dataSize: usize,
pData: *mut ::std::os::raw::c_void,
_stride: VkDeviceSize,
_flags: VkQueryResultFlags,
) -> VkResult {
unimplemented!()
error!("Query pools are not implemented");
let slice = unsafe {
slice::from_raw_parts_mut(pData as *mut u8, dataSize)
};
for d in slice {
*d = 0; //TODO
}
VkResult::VK_ERROR_DEVICE_LOST
}
#[inline]
pub extern "C" fn gfxCreateBuffer(
@ -1307,13 +1315,8 @@ pub extern "C" fn gfxCreateImage(
info.samples,
),
info.mipLevels as _,
match conv::map_format(info.format) {
Some(format) => format,
None => {
error!("Attempted to create an image with format {:?}", info.format);
return VkResult::VK_ERROR_OUT_OF_HOST_MEMORY
}
},
conv::map_format(info.format)
.expect(&format!("Unsupported image format: {:?}", info.format)),
conv::map_tiling(info.tiling),
conv::map_image_usage(info.usage),
unsafe { mem::transmute(info.flags) },
@ -3375,7 +3378,7 @@ pub extern "C" fn gfxCmdBeginQuery(
_query: u32,
_flags: VkQueryControlFlags,
) {
unimplemented!()
error!("Query pools are not implemented");
}
#[inline]
pub extern "C" fn gfxCmdEndQuery(
@ -3383,7 +3386,7 @@ pub extern "C" fn gfxCmdEndQuery(
_queryPool: VkQueryPool,
_query: u32,
) {
unimplemented!()
error!("Query pools are not implemented");
}
#[inline]
pub extern "C" fn gfxCmdResetQueryPool(
@ -3392,7 +3395,7 @@ pub extern "C" fn gfxCmdResetQueryPool(
_firstQuery: u32,
_queryCount: u32,
) {
unimplemented!()
error!("Query pools are not implemented");
}
#[inline]
pub extern "C" fn gfxCmdWriteTimestamp(
@ -3546,7 +3549,7 @@ pub extern "C" fn gfxGetPhysicalDeviceSurfaceCapabilitiesKHR(
},
minImageExtent: conv::extent2d_from_hal(caps.extents.start),
maxImageExtent: conv::extent2d_from_hal(caps.extents.end),
maxImageArrayLayers: caps.max_image_layers,
maxImageArrayLayers: caps.max_image_layers as _,
supportedTransforms: VkSurfaceTransformFlagBitsKHR::VK_SURFACE_TRANSFORM_IDENTITY_BIT_KHR
as _,
currentTransform: VkSurfaceTransformFlagBitsKHR::VK_SURFACE_TRANSFORM_IDENTITY_BIT_KHR,
@ -3633,8 +3636,12 @@ pub extern "C" fn gfxCreateSwapchainKHR(
image_count: info.minImageCount,
image_usage: conv::map_image_usage(info.imageUsage),
};
let (swapchain, backbuffers) = gpu.device
.create_swapchain(&mut info.surface.clone(), config);
let (swapchain, backbuffers) = gpu.device.create_swapchain(
&mut info.surface.clone(),
config,
info.oldSwapchain.unbox().map(|s| s.raw),
&conv::map_extent2d(info.imageExtent),
);
let images = match backbuffers {
hal::Backbuffer::Images(images) => images
@ -3917,8 +3924,8 @@ pub extern "C" fn gfxAcquireNextImageKHR(
None => FrameSync::Fence(&*fence),
};
let frame = swapchain.raw.acquire_frame(sync);
unsafe { *pImageIndex = frame.id() as _; }
let frame = swapchain.raw.acquire_frame(sync).unwrap();
unsafe { *pImageIndex = frame; }
VkResult::VK_SUCCESS
}
@ -3929,18 +3936,24 @@ pub extern "C" fn gfxQueuePresentKHR(
) -> VkResult {
let info = unsafe { &*pPresentInfo };
let swapchains = unsafe {
slice::from_raw_parts_mut(info.pSwapchains as *mut VkSwapchainKHR, info.swapchainCount as _)
.into_iter()
.map(|swapchain| &mut swapchain.raw)
let swapchain_slice = unsafe {
slice::from_raw_parts(info.pSwapchains, info.swapchainCount as _)
};
let index_slice = unsafe {
slice::from_raw_parts(info.pImageIndices, info.swapchainCount as _)
};
let swapchains = swapchain_slice
.into_iter()
.zip(index_slice)
.map(|(swapchain, index)| (&swapchain.raw, *index));
let wait_semaphores = unsafe {
slice::from_raw_parts(info.pWaitSemaphores, info.waitSemaphoreCount as _)
.into_iter()
.map(|semaphore| &**semaphore)
};
queue.present(swapchains, wait_semaphores);
queue.present(swapchains, wait_semaphores).unwrap();
VkResult::VK_SUCCESS
}