From 52dcdd097bd7f2d5d009315895f2324841e51d48 Mon Sep 17 00:00:00 2001 From: Dzmitry Malyshau Date: Sat, 12 May 2018 21:17:49 -0400 Subject: [PATCH] Clear image update --- Cargo.lock | 8 ++-- Makefile | 8 ++-- libportability-gfx/Cargo.toml | 1 + libportability-gfx/src/conv.rs | 12 +++++- libportability-gfx/src/impls.rs | 72 ++++++++++++++++++++++----------- libportability-gfx/src/lib.rs | 4 ++ 6 files changed, 71 insertions(+), 34 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 07abe68..e7b2462 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -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#10f87e31670448b63a9449b83cddae250af66370" +source = "git+https://github.com/gfx-rs/gfx#f10a8fb4eda0e899a9e3e35777ebf0517b0fc77d" 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#10f87e31670448b63a9449b83cddae250af66370" +source = "git+https://github.com/gfx-rs/gfx#f10a8fb4eda0e899a9e3e35777ebf0517b0fc77d" dependencies = [ "block 0.1.6 (registry+https://github.com/rust-lang/crates.io-index)", "cocoa 0.15.0 (registry+https://github.com/rust-lang/crates.io-index)", @@ -288,7 +288,7 @@ dependencies = [ [[package]] name = "gfx-backend-vulkan" version = "0.1.0" -source = "git+https://github.com/gfx-rs/gfx#10f87e31670448b63a9449b83cddae250af66370" +source = "git+https://github.com/gfx-rs/gfx#f10a8fb4eda0e899a9e3e35777ebf0517b0fc77d" dependencies = [ "ash 0.24.0 (registry+https://github.com/rust-lang/crates.io-index)", "byteorder 1.2.2 (registry+https://github.com/rust-lang/crates.io-index)", @@ -306,7 +306,7 @@ dependencies = [ [[package]] name = "gfx-hal" version = "0.1.0" -source = "git+https://github.com/gfx-rs/gfx#10f87e31670448b63a9449b83cddae250af66370" +source = "git+https://github.com/gfx-rs/gfx#f10a8fb4eda0e899a9e3e35777ebf0517b0fc77d" 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)", diff --git a/Makefile b/Makefile index a445852..5e7c478 100644 --- a/Makefile +++ b/Makefile @@ -91,12 +91,12 @@ cts-pick: $(TARGET) ($(DEQP) -n $(name)) cts-debug: $(TARGET) - (cd $(DEQP_DIR) && $(DEBUGGER) ./deqp-vk -n $(name)) + #(cd $(DEQP_DIR) && LD_LIBRARY_PATH=$(FULL_LIBRARY_PATH) $(DEBUGGER) ./deqp-vk -n $(name)) + LD_LIBRARY_PATH=$(FULL_LIBRARY_PATH) $(DEBUGGER) $(DEQP_DIR)/deqp-vk -n $(name) clean: rm -f $(OBJECTS) $(TARGET) $(BINDING) cargo clean -cherry: - cd $(CHERRY_DIR) - LD_LIBRARY_PATH=$(FULL_LIBRARY_PATH) go run server.go +cherry: $(TARGET) + cd $(CHERRY_DIR) && RUST_LOG=warn LD_LIBRARY_PATH=$(FULL_LIBRARY_PATH) go run server.go diff --git a/libportability-gfx/Cargo.toml b/libportability-gfx/Cargo.toml index b884c65..2e9abb2 100644 --- a/libportability-gfx/Cargo.toml +++ b/libportability-gfx/Cargo.toml @@ -40,4 +40,5 @@ optional = true [target.'cfg(target_os = "macos")'.dependencies.gfx-backend-metal] git = "https://github.com/gfx-rs/gfx" #path = "../../gfx/src/backend/metal" +features = ["metal_default_capture_scope"] optional = true diff --git a/libportability-gfx/src/conv.rs b/libportability-gfx/src/conv.rs index 77b86af..9a1d10f 100644 --- a/libportability-gfx/src/conv.rs +++ b/libportability-gfx/src/conv.rs @@ -170,9 +170,17 @@ pub fn map_subresource_range(subresource: VkImageSubresourceRange) -> image::Sub image::SubresourceRange { aspects: map_aspect(subresource.aspectMask), levels: subresource.baseMipLevel as _ - ..(subresource.baseMipLevel + subresource.levelCount) as _, + .. if subresource.levelCount as i32 == VK_REMAINING_MIP_LEVELS { + !0 + } else { + (subresource.baseMipLevel + subresource.levelCount) as _ + }, layers: subresource.baseArrayLayer as _ - ..(subresource.baseArrayLayer + subresource.layerCount) as _, + .. if subresource.layerCount as i32 == VK_REMAINING_ARRAY_LAYERS { + !0 + } else { + (subresource.baseArrayLayer + subresource.layerCount) as _ + }, } } diff --git a/libportability-gfx/src/impls.rs b/libportability-gfx/src/impls.rs index 83c4553..8b0b17b 100644 --- a/libportability-gfx/src/impls.rs +++ b/libportability-gfx/src/impls.rs @@ -37,13 +37,6 @@ pub extern "C" fn gfxCreateInstance( _pAllocator: *const VkAllocationCallbacks, pInstance: *mut VkInstance, ) -> VkResult { - // Note: is this the best place to enable logging? - #[cfg(feature = "env_logger")] - { - use env_logger; - env_logger::init(); - } - let backend = back::Instance::create("portability", 1); let adapters = backend .enumerate_adapters() @@ -1756,8 +1749,9 @@ pub extern "C" fn gfxCreateGraphicsPipelines( depth_bounds: if dyn_states.iter().any(|&ds| ds == VkDynamicState::VK_DYNAMIC_STATE_DEPTH_BOUNDS) { None } else { - None // TODO - } + unsafe { info.pDepthStencilState.as_ref() } + .map(|db| db.minDepthBounds .. db.maxDepthBounds) + }, }; let layout = &*info.layout; @@ -3126,25 +3120,55 @@ pub extern "C" fn gfxCmdFillBuffer( } #[inline] pub extern "C" fn gfxCmdClearColorImage( - _commandBuffer: VkCommandBuffer, - _image: VkImage, - _imageLayout: VkImageLayout, - _pColor: *const VkClearColorValue, - _rangeCount: u32, - _pRanges: *const VkImageSubresourceRange, + mut commandBuffer: VkCommandBuffer, + image: VkImage, + imageLayout: VkImageLayout, + pColor: *const VkClearColorValue, + rangeCount: u32, + pRanges: *const VkImageSubresourceRange, ) { - unimplemented!() + let subresource_ranges = unsafe { + slice::from_raw_parts(pRanges, rangeCount as _) + }; + commandBuffer.clear_image( + match *image { + Image::Image(ref image) => image, + Image::Unbound(_) => panic!("Bound image expected!"), + }, + conv::map_image_layout(imageLayout), + unsafe { mem::transmute(*pColor) }, + unsafe { mem::zeroed() }, + subresource_ranges + .iter() + .cloned() + .map(conv::map_subresource_range), + ); } #[inline] pub extern "C" fn gfxCmdClearDepthStencilImage( - _commandBuffer: VkCommandBuffer, - _image: VkImage, - _imageLayout: VkImageLayout, - _pDepthStencil: *const VkClearDepthStencilValue, - _rangeCount: u32, - _pRanges: *const VkImageSubresourceRange, + mut commandBuffer: VkCommandBuffer, + image: VkImage, + imageLayout: VkImageLayout, + pDepthStencil: *const VkClearDepthStencilValue, + rangeCount: u32, + pRanges: *const VkImageSubresourceRange, ) { - unimplemented!() + let subresource_ranges = unsafe { + slice::from_raw_parts(pRanges, rangeCount as _) + }; + commandBuffer.clear_image( + match *image { + Image::Image(ref image) => image, + Image::Unbound(_) => panic!("Bound image expected!"), + }, + conv::map_image_layout(imageLayout), + unsafe { mem::zeroed() }, + unsafe { mem::transmute(*pDepthStencil) }, + subresource_ranges + .iter() + .cloned() + .map(conv::map_subresource_range), + ); } #[inline] pub extern "C" fn gfxCmdClearAttachments( @@ -3398,7 +3422,7 @@ pub extern "C" fn gfxCmdBeginRenderPass( }; let contents = conv::map_subpass_contents(contents); - commandBuffer.begin_render_pass_raw( + commandBuffer.begin_render_pass( &*info.renderPass, &*info.framebuffer, render_area, diff --git a/libportability-gfx/src/lib.rs b/libportability-gfx/src/lib.rs index 8ef395d..56d1ec2 100644 --- a/libportability-gfx/src/lib.rs +++ b/libportability-gfx/src/lib.rs @@ -31,6 +31,10 @@ use std::collections::HashMap; pub use impls::*; +#[cfg(feature = "env_logger")] +lazy_static! { + static ref _LOGGER: () = env_logger::init(); +} // Vulkan objects pub type VkInstance = Handle;