From 99161cbeb50d3ecb8201b7794e58baa8c619b79b Mon Sep 17 00:00:00 2001 From: Rukai Date: Sat, 4 Apr 2020 13:54:43 +1100 Subject: [PATCH] Use crates.io release of peek-poke --- Cargo.lock | 30 ++++++++++++++++++++++-------- ffi/wgpu.h | 2 +- wgpu-core/Cargo.toml | 2 +- wgpu-core/src/command/compute.rs | 14 ++++++++++---- wgpu-core/src/command/mod.rs | 29 ++++++++++++++++++++++------- wgpu-core/src/command/render.rs | 19 +++++++++++++------ wgpu-core/src/device/mod.rs | 1 + wgpu-core/src/id.rs | 13 ++++++++++--- wgpu-types/Cargo.toml | 2 +- wgpu-types/src/lib.rs | 13 +++++++------ 10 files changed, 88 insertions(+), 37 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 5b88e5c4e1..1a052c3d87 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -445,19 +445,21 @@ dependencies = [ [[package]] name = "peek-poke" version = "0.2.0" -source = "git+https://github.com/kvark/peek-poke?rev=969bd7fe2be1a83f87916dc8b388c63cfd457075#969bd7fe2be1a83f87916dc8b388c63cfd457075" +source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ - "peek-poke-derive 0.2.0 (git+https://github.com/kvark/peek-poke?rev=969bd7fe2be1a83f87916dc8b388c63cfd457075)", + "peek-poke-derive 0.2.1 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] name = "peek-poke-derive" -version = "0.2.0" -source = "git+https://github.com/kvark/peek-poke?rev=969bd7fe2be1a83f87916dc8b388c63cfd457075#969bd7fe2be1a83f87916dc8b388c63cfd457075" +version = "0.2.1" +source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "proc-macro2 1.0.9 (registry+https://github.com/rust-lang/crates.io-index)", "quote 1.0.3 (registry+https://github.com/rust-lang/crates.io-index)", "syn 1.0.17 (registry+https://github.com/rust-lang/crates.io-index)", + "synstructure 0.12.3 (registry+https://github.com/rust-lang/crates.io-index)", + "unicode-xid 0.2.0 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] @@ -560,6 +562,17 @@ dependencies = [ "unicode-xid 0.2.0 (registry+https://github.com/rust-lang/crates.io-index)", ] +[[package]] +name = "synstructure" +version = "0.12.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +dependencies = [ + "proc-macro2 1.0.9 (registry+https://github.com/rust-lang/crates.io-index)", + "quote 1.0.3 (registry+https://github.com/rust-lang/crates.io-index)", + "syn 1.0.17 (registry+https://github.com/rust-lang/crates.io-index)", + "unicode-xid 0.2.0 (registry+https://github.com/rust-lang/crates.io-index)", +] + [[package]] name = "typenum" version = "1.11.2" @@ -657,7 +670,7 @@ dependencies = [ "gfx-memory 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)", "log 0.4.8 (registry+https://github.com/rust-lang/crates.io-index)", "parking_lot 0.10.0 (registry+https://github.com/rust-lang/crates.io-index)", - "peek-poke 0.2.0 (git+https://github.com/kvark/peek-poke?rev=969bd7fe2be1a83f87916dc8b388c63cfd457075)", + "peek-poke 0.2.0 (registry+https://github.com/rust-lang/crates.io-index)", "serde 1.0.105 (registry+https://github.com/rust-lang/crates.io-index)", "smallvec 1.2.0 (registry+https://github.com/rust-lang/crates.io-index)", "vec_map 0.8.1 (registry+https://github.com/rust-lang/crates.io-index)", @@ -693,7 +706,7 @@ name = "wgpu-types" version = "0.1.0" dependencies = [ "bitflags 1.2.1 (registry+https://github.com/rust-lang/crates.io-index)", - "peek-poke 0.2.0 (git+https://github.com/kvark/peek-poke?rev=969bd7fe2be1a83f87916dc8b388c63cfd457075)", + "peek-poke 0.2.0 (registry+https://github.com/rust-lang/crates.io-index)", "serde 1.0.105 (registry+https://github.com/rust-lang/crates.io-index)", ] @@ -783,8 +796,8 @@ dependencies = [ "checksum objc_exception 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)" = "ad970fb455818ad6cba4c122ad012fae53ae8b4795f86378bce65e4f6bab2ca4" "checksum parking_lot 0.10.0 (registry+https://github.com/rust-lang/crates.io-index)" = "92e98c49ab0b7ce5b222f2cc9193fc4efe11c6d0bd4f648e374684a6857b1cfc" "checksum parking_lot_core 0.7.0 (registry+https://github.com/rust-lang/crates.io-index)" = "7582838484df45743c8434fbff785e8edf260c28748353d44bc0da32e0ceabf1" -"checksum peek-poke 0.2.0 (git+https://github.com/kvark/peek-poke?rev=969bd7fe2be1a83f87916dc8b388c63cfd457075)" = "" -"checksum peek-poke-derive 0.2.0 (git+https://github.com/kvark/peek-poke?rev=969bd7fe2be1a83f87916dc8b388c63cfd457075)" = "" +"checksum peek-poke 0.2.0 (registry+https://github.com/rust-lang/crates.io-index)" = "d93fd6a575ebf1ac2668d08443c97a22872cfb463fd8b7ddd141e9f6be59af2f" +"checksum peek-poke-derive 0.2.1 (registry+https://github.com/rust-lang/crates.io-index)" = "6fb44a25c5bba983be0fc8592dfaf3e6d0935ce8be0c6b15b2a39507af34a926" "checksum pkg-config 0.3.17 (registry+https://github.com/rust-lang/crates.io-index)" = "05da548ad6865900e60eaba7f589cc0783590a92e940c26953ff81ddbab2d677" "checksum proc-macro2 1.0.9 (registry+https://github.com/rust-lang/crates.io-index)" = "6c09721c6781493a2a492a96b5a5bf19b65917fe6728884e7c44dd0c60ca3435" "checksum quote 1.0.3 (registry+https://github.com/rust-lang/crates.io-index)" = "2bdc6c187c65bca4260c9011c9e3132efe4909da44726bad24cf7572ae338d7f" @@ -799,6 +812,7 @@ dependencies = [ "checksum spirv_cross 0.18.0 (registry+https://github.com/rust-lang/crates.io-index)" = "946216f8793f7199e3ea5b995ee8dc20a0ace1fcf46293a0ef4c17e1d046dbde" "checksum storage-map 0.2.0 (registry+https://github.com/rust-lang/crates.io-index)" = "fd0a4829a5c591dc24a944a736d6b1e4053e51339a79fd5d4702c4c999a9c45e" "checksum syn 1.0.17 (registry+https://github.com/rust-lang/crates.io-index)" = "0df0eb663f387145cab623dea85b09c2c5b4b0aef44e945d928e682fce71bb03" +"checksum synstructure 0.12.3 (registry+https://github.com/rust-lang/crates.io-index)" = "67656ea1dc1b41b1451851562ea232ec2e5a80242139f7e679ceccfb5d61f545" "checksum typenum 1.11.2 (registry+https://github.com/rust-lang/crates.io-index)" = "6d2783fe2d6b8c1101136184eb41be8b1ad379e4657050b8aaff0c79ee7575f9" "checksum unicode-xid 0.2.0 (registry+https://github.com/rust-lang/crates.io-index)" = "826e7639553986605ec5979c7dd957c7895e93eabed50ab2ffa7f6128a75097c" "checksum uom 0.26.0 (registry+https://github.com/rust-lang/crates.io-index)" = "4cec796ec5f7ac557631709079168286056205c51c60aac33f51764bdc7b8dc4" diff --git a/ffi/wgpu.h b/ffi/wgpu.h index 375221640f..7d7e7bfe52 100644 --- a/ffi/wgpu.h +++ b/ffi/wgpu.h @@ -2,7 +2,7 @@ * License, v. 2.0. If a copy of the MPL was not distributed with this * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ -/* Generated with cbindgen:0.13.2 */ +/* Generated with cbindgen:0.14.0 */ /* DO NOT MODIFY THIS MANUALLY! This file was generated using cbindgen. * To generate this file: diff --git a/wgpu-core/Cargo.toml b/wgpu-core/Cargo.toml index 647492e41d..c26fb55da6 100644 --- a/wgpu-core/Cargo.toml +++ b/wgpu-core/Cargo.toml @@ -32,7 +32,7 @@ gfx-backend-empty = "0.5" gfx-descriptor = "0.1" gfx-memory = "0.1" parking_lot = "0.10" -peek-poke = { git = "https://github.com/kvark/peek-poke", rev = "969bd7fe2be1a83f87916dc8b388c63cfd457075" } +peek-poke = "0.2" smallvec = "1" vec_map = "0.8" diff --git a/wgpu-core/src/command/compute.rs b/wgpu-core/src/command/compute.rs index e503b6bea7..8790064558 100644 --- a/wgpu-core/src/command/compute.rs +++ b/wgpu-core/src/command/compute.rs @@ -15,7 +15,7 @@ use crate::{ use wgt::{BufferAddress, BufferUsage, DynamicOffset, BIND_BUFFER_ALIGNMENT}; use hal::command::CommandBuffer as _; -use peek_poke::{Peek, PeekCopy, Poke}; +use peek_poke::{Peek, PeekPoke, Poke}; use std::iter; @@ -25,7 +25,7 @@ enum PipelineState { Set, } -#[derive(Clone, Copy, Debug, PeekCopy, Poke)] +#[derive(Clone, Copy, Debug, PeekPoke)] enum ComputeCommand { SetBindGroup { index: u8, @@ -42,6 +42,12 @@ enum ComputeCommand { End, } +impl Default for ComputeCommand { + fn default() -> Self { + ComputeCommand::End + } +} + impl super::RawPass { pub unsafe fn new_compute(parent: id::CommandEncoderId) -> Self { Self::from_vec(Vec::::with_capacity(1), parent) @@ -90,7 +96,7 @@ impl Global { let mut command = ComputeCommand::Dispatch([0; 3]); // dummy loop { assert!(unsafe { peeker.add(ComputeCommand::max_size()) } <= raw_data_end); - peeker = unsafe { command.peek_from(peeker) }; + peeker = unsafe { ComputeCommand::peek_from(peeker, &mut command) }; match command { ComputeCommand::SetBindGroup { index, num_dynamic_offsets, bind_group_id, phantom_offsets } => { let (new_peeker, offsets) = unsafe { @@ -256,7 +262,7 @@ use wgt::{BufferAddress, DynamicOffset}; index: index.try_into().unwrap(), num_dynamic_offsets: offset_length.try_into().unwrap(), bind_group_id, - phantom_offsets: PhantomSlice::new(), + phantom_offsets: PhantomSlice::default(), }); pass.encode_slice( slice::from_raw_parts(offsets, offset_length), diff --git a/wgpu-core/src/command/mod.rs b/wgpu-core/src/command/mod.rs index 765aaa256c..623f2a0c03 100644 --- a/wgpu-core/src/command/mod.rs +++ b/wgpu-core/src/command/mod.rs @@ -28,6 +28,8 @@ use crate::{ Stored, }; +use peek_poke::PeekPoke; + use std::{ marker::PhantomData, mem, @@ -37,14 +39,16 @@ use std::{ }; -#[derive(Clone, Copy, Debug, peek_poke::PeekCopy, peek_poke::Poke)] +#[derive(Clone, Copy, Debug, PeekPoke)] struct PhantomSlice(PhantomData); -impl PhantomSlice { - fn new() -> Self { +impl Default for PhantomSlice { + fn default() -> Self { PhantomSlice(PhantomData) } +} +impl PhantomSlice { unsafe fn decode_unaligned<'a>( self, pointer: *const u8, count: usize, bound: *const u8 ) -> (*const u8, &'a [T]) { @@ -197,15 +201,26 @@ impl CommandBuffer { } #[repr(C)] -#[derive(peek_poke::PeekCopy, peek_poke::Poke)] +#[derive(PeekPoke)] struct PassComponent { load_op: wgt::LoadOp, store_op: wgt::StoreOp, clear_value: T, } +// required for PeekPoke +impl Default for PassComponent { + fn default() -> Self { + PassComponent { + load_op: wgt::LoadOp::Clear, + store_op: wgt::StoreOp::Clear, + clear_value: T::default(), + } + } +} + #[repr(C)] -#[derive(peek_poke::PeekCopy, peek_poke::Poke)] +#[derive(Default, PeekPoke)] struct RawRenderPassColorAttachmentDescriptor { attachment: u64, resolve_target: u64, @@ -213,7 +228,7 @@ struct RawRenderPassColorAttachmentDescriptor { } #[repr(C)] -#[derive(peek_poke::PeekCopy, peek_poke::Poke)] +#[derive(Default, PeekPoke)] struct RawRenderPassDepthStencilAttachmentDescriptor { attachment: u64, depth: PassComponent, @@ -221,7 +236,7 @@ struct RawRenderPassDepthStencilAttachmentDescriptor { } #[repr(C)] -#[derive(peek_poke::PeekCopy, peek_poke::Poke)] +#[derive(Default, PeekPoke)] struct RawRenderTargets { colors: [RawRenderPassColorAttachmentDescriptor; MAX_COLOR_TARGETS], depth_stencil: RawRenderPassDepthStencilAttachmentDescriptor, diff --git a/wgpu-core/src/command/render.rs b/wgpu-core/src/command/render.rs index e53c8c3558..b771e888c3 100644 --- a/wgpu-core/src/command/render.rs +++ b/wgpu-core/src/command/render.rs @@ -42,7 +42,7 @@ use wgt::{ }; use arrayvec::ArrayVec; use hal::command::CommandBuffer as _; -use peek_poke::{Peek, PeekCopy, Poke}; +use peek_poke::{Peek, PeekPoke, Poke}; use std::{ borrow::Borrow, @@ -67,7 +67,7 @@ pub struct RenderPassDescriptor<'a> { pub depth_stencil_attachment: Option<&'a RenderPassDepthStencilAttachmentDescriptor>, } -#[derive(Clone, Copy, Debug, PeekCopy, Poke)] +#[derive(Clone, Copy, Debug, Default, PeekPoke)] pub struct Rect { pub x: T, pub y: T, @@ -75,7 +75,7 @@ pub struct Rect { pub h: T, } -#[derive(Clone, Copy, Debug, PeekCopy, Poke)] +#[derive(Clone, Copy, Debug, PeekPoke)] enum RenderCommand { SetBindGroup { index: u8, @@ -128,6 +128,13 @@ enum RenderCommand { End, } +// required for PeekPoke +impl Default for RenderCommand { + fn default() -> Self { + RenderCommand::End + } +} + impl super::RawPass { pub unsafe fn new_render(parent_id: id::CommandEncoderId, desc: &RenderPassDescriptor) -> Self { let mut pass = Self::from_vec(Vec::::with_capacity(1), parent_id); @@ -334,7 +341,7 @@ impl Global { let mut targets: RawRenderTargets = unsafe { mem::zeroed() }; assert!(unsafe { peeker.add(RawRenderTargets::max_size()) <= raw_data_end }); - peeker = unsafe { targets.peek_from(peeker) }; + peeker = unsafe { RawRenderTargets::peek_from(peeker, &mut targets) }; let color_attachments = targets.colors .iter() @@ -829,7 +836,7 @@ impl Global { }; loop { assert!(unsafe { peeker.add(RenderCommand::max_size()) } <= raw_data_end); - peeker = unsafe { command.peek_from(peeker) }; + peeker = unsafe { RenderCommand::peek_from(peeker, &mut command) }; match command { RenderCommand::SetBindGroup { index, num_dynamic_offsets, bind_group_id, phantom_offsets } => { let (new_peeker, offsets) = unsafe { @@ -1190,7 +1197,7 @@ pub mod render_ffi { index: index.try_into().unwrap(), num_dynamic_offsets: offset_length.try_into().unwrap(), bind_group_id, - phantom_offsets: PhantomSlice::new(), + phantom_offsets: PhantomSlice::default(), }); pass.encode_slice( slice::from_raw_parts(offsets, offset_length), diff --git a/wgpu-core/src/device/mod.rs b/wgpu-core/src/device/mod.rs index 0a123e50e9..449ff62e22 100644 --- a/wgpu-core/src/device/mod.rs +++ b/wgpu-core/src/device/mod.rs @@ -663,6 +663,7 @@ impl Global { let hub = B::hub(self); let mut token = Token::root(); + log::info!("Buffer {:?} is dropped", buffer_id); let device_id = { let (mut buffer_guard, _) = hub.buffers.write(&mut token); let buffer = &mut buffer_guard[buffer_id]; diff --git a/wgpu-core/src/id.rs b/wgpu-core/src/id.rs index a06c77d389..fcda07b00d 100644 --- a/wgpu-core/src/id.rs +++ b/wgpu-core/src/id.rs @@ -16,6 +16,13 @@ type Dummy = crate::backend::Empty; #[cfg_attr(feature = "serde", derive(Serialize, Deserialize), serde(crate="serde_crate"))] pub struct Id(NonZeroU64, PhantomData); +// required for PeekPoke +impl Default for Id { + fn default() -> Self { + Id(unsafe { NonZeroU64::new_unchecked(!0) }, PhantomData) + } +} + impl Id { pub fn backend(self) -> Backend { match self.0.get() >> (64 - BACKEND_BITS) as u8 { @@ -76,10 +83,10 @@ unsafe impl peek_poke::Poke for Id { } impl peek_poke::Peek for Id { - unsafe fn peek_from(&mut self, mut data: *const u8) -> *const u8 { + unsafe fn peek_from(mut data: *const u8, this: *mut Self) -> *const u8 { let mut v = 0u64; - data = v.peek_from(data); - self.0 = NonZeroU64::new(v).unwrap(); + data = u64::peek_from(data, &mut v); + (*this).0 = NonZeroU64::new(v).unwrap(); data } } diff --git a/wgpu-types/Cargo.toml b/wgpu-types/Cargo.toml index 068fb1ade9..2c485c7f5a 100644 --- a/wgpu-types/Cargo.toml +++ b/wgpu-types/Cargo.toml @@ -17,4 +17,4 @@ license = "MPL-2.0" [dependencies] bitflags = "1.0" serde = { version = "1.0", features = ["serde_derive"], optional = true } -peek-poke = { git = "https://github.com/kvark/peek-poke", rev = "969bd7fe2be1a83f87916dc8b388c63cfd457075", optional = true } +peek-poke = { version = "0.2", optional = true } diff --git a/wgpu-types/src/lib.rs b/wgpu-types/src/lib.rs index 90c65f8776..527be983d3 100644 --- a/wgpu-types/src/lib.rs +++ b/wgpu-types/src/lib.rs @@ -6,7 +6,7 @@ use std::{io, slice, ptr}; #[cfg(feature = "serde")] use serde::{Serialize, Deserialize}; #[cfg(feature = "peek-poke")] -use peek_poke::{PeekCopy, Poke}; +use peek_poke::{PeekPoke}; #[repr(u8)] #[derive(Clone, Copy, Debug, PartialEq, Eq, Hash)] @@ -621,7 +621,7 @@ pub struct SwapChainDescriptor { #[repr(C)] #[derive(Copy, Clone, Debug, Hash, Eq, PartialEq)] #[cfg_attr(feature = "serde", derive(Serialize, Deserialize))] -#[cfg_attr(feature = "peek-poke", derive(PeekCopy, Poke))] +#[cfg_attr(feature = "peek-poke", derive(PeekPoke))] pub enum LoadOp { Clear = 0, Load = 1, @@ -630,7 +630,7 @@ pub enum LoadOp { #[repr(C)] #[derive(Copy, Clone, Debug, Hash, Eq, PartialEq)] #[cfg_attr(feature = "serde", derive(Serialize, Deserialize))] -#[cfg_attr(feature = "peek-poke", derive(PeekCopy, Poke))] +#[cfg_attr(feature = "peek-poke", derive(PeekPoke))] pub enum StoreOp { Clear = 0, Store = 1, @@ -639,6 +639,7 @@ pub enum StoreOp { #[repr(C)] #[derive(Clone, Debug)] #[cfg_attr(feature = "serde", derive(Serialize, Deserialize))] +#[cfg_attr(feature = "peek-poke", derive(PeekPoke))] pub struct RenderPassColorAttachmentDescriptorBase { pub attachment: T, pub resolve_target: Option, @@ -650,7 +651,7 @@ pub struct RenderPassColorAttachmentDescriptorBase { #[repr(C)] #[derive(Clone, Debug)] #[cfg_attr(feature = "serde", derive(Serialize, Deserialize))] -#[cfg_attr(feature = "peek-poke", derive(PeekCopy, Poke))] +#[cfg_attr(feature = "peek-poke", derive(PeekPoke))] pub struct RenderPassDepthStencilAttachmentDescriptorBase { pub attachment: T, pub depth_load_op: LoadOp, @@ -662,9 +663,9 @@ pub struct RenderPassDepthStencilAttachmentDescriptorBase { } #[repr(C)] -#[derive(Clone, Copy, Debug, PartialEq)] +#[derive(Clone, Copy, Debug, Default, PartialEq)] #[cfg_attr(feature = "serde", derive(Serialize, Deserialize))] -#[cfg_attr(feature = "peek-poke", derive(PeekCopy, Poke))] +#[cfg_attr(feature = "peek-poke", derive(PeekPoke))] pub struct Color { pub r: f64, pub g: f64,