From f59c6f9f2f1daa2349de6b123d0c4c6bae3d158e Mon Sep 17 00:00:00 2001 From: Serhii Plyhun Date: Mon, 29 Apr 2019 22:34:03 +0200 Subject: [PATCH] Scissor test --- Cargo.lock | 14 +++++++------- wgpu-bindings/wgpu.h | 6 ++++++ wgpu-native/Cargo.toml | 2 +- wgpu-native/src/command/render.rs | 27 +++++++++++++++++++++++++++ wgpu-rs/Cargo.toml | 4 ++-- wgpu-rs/src/lib.rs | 4 ++++ 6 files changed, 47 insertions(+), 10 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 670367e98..5ef9fbc9d 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -320,8 +320,8 @@ name = "examples" version = "0.1.0" dependencies = [ "env_logger 0.5.13 (registry+https://github.com/rust-lang/crates.io-index)", - "wgpu 0.2.2", - "wgpu-native 0.2.6", + "wgpu 0.2.3", + "wgpu-native 0.2.7", ] [[package]] @@ -498,7 +498,7 @@ dependencies = [ "env_logger 0.5.13 (registry+https://github.com/rust-lang/crates.io-index)", "glsl-to-spirv 0.1.7 (registry+https://github.com/rust-lang/crates.io-index)", "log 0.4.6 (registry+https://github.com/rust-lang/crates.io-index)", - "wgpu 0.2.2", + "wgpu 0.2.3", ] [[package]] @@ -1384,10 +1384,10 @@ dependencies = [ [[package]] name = "wgpu" -version = "0.2.2" +version = "0.2.3" dependencies = [ "arrayvec 0.4.10 (registry+https://github.com/rust-lang/crates.io-index)", - "wgpu-native 0.2.6", + "wgpu-native 0.2.7", ] [[package]] @@ -1399,7 +1399,7 @@ dependencies = [ [[package]] name = "wgpu-native" -version = "0.2.6" +version = "0.2.7" dependencies = [ "arrayvec 0.4.10 (registry+https://github.com/rust-lang/crates.io-index)", "bitflags 1.0.4 (registry+https://github.com/rust-lang/crates.io-index)", @@ -1425,7 +1425,7 @@ dependencies = [ "log 0.4.6 (registry+https://github.com/rust-lang/crates.io-index)", "parking_lot 0.7.1 (registry+https://github.com/rust-lang/crates.io-index)", "serde 1.0.89 (registry+https://github.com/rust-lang/crates.io-index)", - "wgpu-native 0.2.6", + "wgpu-native 0.2.7", ] [[package]] diff --git a/wgpu-bindings/wgpu.h b/wgpu-bindings/wgpu.h index 2b9c59c00..9d4540499 100644 --- a/wgpu-bindings/wgpu.h +++ b/wgpu-bindings/wgpu.h @@ -804,6 +804,12 @@ void wgpu_render_pass_set_index_buffer(WGPURenderPassId pass_id, void wgpu_render_pass_set_pipeline(WGPURenderPassId pass_id, WGPURenderPipelineId pipeline_id); +void wgpu_render_pass_set_scissor_rect(WGPURenderPassId pass_id, + uint32_t x, + uint32_t y, + uint32_t w, + uint32_t h); + void wgpu_render_pass_set_vertex_buffers(WGPURenderPassId pass_id, const WGPUBufferId *buffer_ptr, const uint32_t *offset_ptr, diff --git a/wgpu-native/Cargo.toml b/wgpu-native/Cargo.toml index a344c95b7..c5f7502d6 100644 --- a/wgpu-native/Cargo.toml +++ b/wgpu-native/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "wgpu-native" -version = "0.2.6" +version = "0.2.7" authors = [ "Dzmitry Malyshau ", "Joshua Groves ", diff --git a/wgpu-native/src/command/render.rs b/wgpu-native/src/command/render.rs index 51aa162f0..ae643b791 100644 --- a/wgpu-native/src/command/render.rs +++ b/wgpu-native/src/command/render.rs @@ -303,3 +303,30 @@ pub extern "C" fn wgpu_render_pass_set_blend_color( pass.raw.set_blend_constants(conv::map_color(color)); } } + +#[no_mangle] +pub extern "C" fn wgpu_render_pass_set_scissor_rect( + pass_id: RenderPassId, + x: u32, + y: u32, + w: u32, + h: u32, +) { + let mut pass_guard = HUB.render_passes.write(); + let pass = &mut pass_guard[pass_id]; + + unsafe { + use std::convert::TryFrom; + use std::i16; + + pass.raw.set_scissors( + 0, + &[hal::pso::Rect { + x: i16::try_from(x).unwrap_or(0), + y: i16::try_from(y).unwrap_or(0), + w: i16::try_from(w).unwrap_or(i16::MAX), + h: i16::try_from(h).unwrap_or(i16::MAX), + }], + ); + } +} diff --git a/wgpu-rs/Cargo.toml b/wgpu-rs/Cargo.toml index 5ab29b961..20ad2670f 100644 --- a/wgpu-rs/Cargo.toml +++ b/wgpu-rs/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "wgpu" -version = "0.2.2" +version = "0.2.3" authors = [ "Dzmitry Malyshau ", "Joshua Groves ", @@ -23,5 +23,5 @@ dx12 = ["wgpu-native/gfx-backend-dx12"] vulkan = ["wgpu-native/gfx-backend-vulkan"] [dependencies] -wgpu-native = { version = "0.2.5", path = "../wgpu-native", features = ["local"] } +wgpu-native = { version = "0.2.7", path = "../wgpu-native", features = ["local"] } arrayvec = "0.4" diff --git a/wgpu-rs/src/lib.rs b/wgpu-rs/src/lib.rs index f16cfd88a..48261116e 100644 --- a/wgpu-rs/src/lib.rs +++ b/wgpu-rs/src/lib.rs @@ -807,6 +807,10 @@ impl<'a> RenderPass<'a> { ); } + pub fn set_scissor_rect(&mut self, x: u32, y: u32, w: u32, h: u32) { + wgn::wgpu_render_pass_set_scissor_rect(self.id, x, y, w, h) + } + pub fn draw(&mut self, vertices: Range, instances: Range) { wgn::wgpu_render_pass_draw( self.id,