Skip to content

Commit

Permalink
Merge gfx-rs#112
Browse files Browse the repository at this point in the history
112: Correctness fixes from 0.2, plus a lot of goodies r=kvark a=kvark

These are changes from gfx-rs#110 back-ported to master.

Co-authored-by: Dzmitry Malyshau <dmalyshau@mozilla.com>
  • Loading branch information
bors[bot] and kvark committed Mar 24, 2019
2 parents cf521d6 + 0b51c8a commit dfa126c
Show file tree
Hide file tree
Showing 20 changed files with 255 additions and 156 deletions.
7 changes: 7 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,12 @@
# Change Log

## v0.2.3 (20-03-2019)
- fixed vertex format mapping
- fixed building with "empty" backend on Windows
- bumped the default descriptor pool size
- fixed host mapping aligments
- validating the uniform buffer offset

## v0.2 (06-03-2019)
- Platforms: iOS/Metal, D3D11
- Crates:
Expand Down
21 changes: 14 additions & 7 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 2 additions & 1 deletion wgpu-native/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "wgpu-native"
version = "0.2.0"
version = "0.2.4"
authors = [
"Dzmitry Malyshau <kvark@mozilla.com>",
"Joshua Groves <josh@joshgroves.com>",
Expand All @@ -25,6 +25,7 @@ window-winit = ["winit", "gfx-backend-empty/winit"]
[dependencies]
arrayvec = "0.4"
bitflags = "1.0"
copyless = "0.1"
lazy_static = "1.1.0"
log = "0.4"
parking_lot = { version = "0.7" }
Expand Down
14 changes: 11 additions & 3 deletions wgpu-native/src/binding_model.rs
Original file line number Diff line number Diff line change
@@ -1,8 +1,14 @@
use crate::track::TrackerSet;
use crate::{BindGroupLayoutId, BufferId, LifeGuard, SamplerId, TextureViewId};
use crate::{
track::TrackerSet,
BindGroupLayoutId, BufferId, LifeGuard, SamplerId, TextureViewId,
};

use arrayvec::ArrayVec;
use bitflags::bitflags;


pub const MAX_BIND_GROUPS: usize = 4;

bitflags! {
#[repr(transparent)]
pub struct ShaderStageFlags: u32 {
Expand All @@ -22,6 +28,7 @@ pub enum BindingType {
}

#[repr(C)]
#[derive(Clone, Debug, Hash)]
pub struct BindGroupLayoutBinding {
pub binding: u32,
pub visibility: ShaderStageFlags,
Expand All @@ -36,6 +43,7 @@ pub struct BindGroupLayoutDescriptor {

pub struct BindGroupLayout<B: hal::Backend> {
pub(crate) raw: B::DescriptorSetLayout,
pub(crate) bindings: Vec<BindGroupLayoutBinding>,
}

#[repr(C)]
Expand All @@ -46,7 +54,7 @@ pub struct PipelineLayoutDescriptor {

pub struct PipelineLayout<B: hal::Backend> {
pub(crate) raw: B::PipelineLayout,
pub(crate) bind_group_layout_ids: Vec<BindGroupLayoutId>,
pub(crate) bind_group_layout_ids: ArrayVec<[BindGroupLayoutId; MAX_BIND_GROUPS]>,
}

#[repr(C)]
Expand Down
24 changes: 15 additions & 9 deletions wgpu-native/src/command/allocator.rs
Original file line number Diff line number Diff line change
@@ -1,15 +1,21 @@
use super::CommandBuffer;
use crate::track::TrackerSet;
use crate::{DeviceId, LifeGuard, Stored, SubmissionIndex};

use hal::command::RawCommandBuffer;
use hal::pool::RawCommandPool;
use hal::Device;
use crate::{
track::TrackerSet,
DeviceId, LifeGuard, Stored, SubmissionIndex,
};

use hal::{
command::RawCommandBuffer,
pool::RawCommandPool,
Device,
};
use parking_lot::Mutex;

use std::collections::HashMap;
use std::sync::atomic::Ordering;
use std::thread;
use std::{
collections::HashMap,
sync::atomic::Ordering,
thread,
};

struct CommandPool<B: hal::Backend> {
raw: B::CommandPool,
Expand Down
5 changes: 4 additions & 1 deletion wgpu-native/src/command/bind.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
use crate::{BindGroupHandle, BindGroupId, BindGroupLayoutId, PipelineLayoutId, Stored};

use copyless::VecHelper as _;


pub struct BindGroupPair {
layout_id: BindGroupLayoutId,
group_id: Stored<BindGroupId>,
Expand Down Expand Up @@ -64,7 +67,7 @@ pub struct Binder {
impl Binder {
pub fn ensure_length(&mut self, length: usize) {
while self.entries.len() < length {
self.entries.push(BindGroupEntry::default());
self.entries.alloc().init(BindGroupEntry::default());
}
}

Expand Down
13 changes: 8 additions & 5 deletions wgpu-native/src/command/compute.rs
Original file line number Diff line number Diff line change
@@ -1,15 +1,18 @@
use crate::command::bind::Binder;
use crate::hub::HUB;
use crate::track::{Stitch, TrackerSet};
use crate::{
command::bind::Binder,
hub::HUB,
track::{Stitch, TrackerSet},
BindGroupId, CommandBuffer, CommandBufferId, ComputePassId, ComputePipelineId, Stored,
};

use hal;
use hal::command::RawCommandBuffer;
use hal::{
self,
command::RawCommandBuffer,
};

use std::iter;


pub struct ComputePass<B: hal::Backend> {
raw: B::CommandBuffer,
cmb_id: Stored<CommandBufferId>,
Expand Down
31 changes: 18 additions & 13 deletions wgpu-native/src/command/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,29 +9,34 @@ pub use self::compute::*;
pub use self::render::*;
pub use self::transfer::*;

use crate::conv;
use crate::device::{
all_buffer_stages, all_image_stages, FramebufferKey, RenderPassContext, RenderPassKey,
};
use crate::hub::{Storage, HUB};
use crate::resource::TexturePlacement;
use crate::swap_chain::{SwapChainLink, SwapImageEpoch};
use crate::track::{DummyUsage, Stitch, TrackerSet};
use crate::{
conv,
device::{
all_buffer_stages, all_image_stages, FramebufferKey, RenderPassContext, RenderPassKey,
},
hub::{Storage, HUB},
resource::TexturePlacement,
swap_chain::{SwapChainLink, SwapImageEpoch},
track::{DummyUsage, Stitch, TrackerSet},
BufferHandle, Color, CommandBufferHandle, CommandBufferId, CommandEncoderId, DeviceId,
LifeGuard, Stored, TextureHandle, TextureUsageFlags, TextureViewId,
};
#[cfg(feature = "local")]
use crate::{ComputePassId, RenderPassId};

use back::Backend;
use hal::command::RawCommandBuffer;
use hal::Device as _Device;
use hal::{
Device as _,
command::RawCommandBuffer,
};
use log::trace;

use std::collections::hash_map::Entry;
use std::thread::ThreadId;
use std::{iter, slice};
use std::{
iter, slice,
collections::hash_map::Entry,
thread::ThreadId,
};


#[repr(C)]
#[derive(Copy, Clone, Debug, Hash, Eq, PartialEq)]
Expand Down
11 changes: 6 additions & 5 deletions wgpu-native/src/command/render.rs
Original file line number Diff line number Diff line change
@@ -1,16 +1,17 @@
use crate::command::bind::Binder;
use crate::device::RenderPassContext;
use crate::hub::HUB;
use crate::resource::BufferUsageFlags;
use crate::track::{Stitch, TrackerSet};
use crate::{
command::bind::Binder,
device::RenderPassContext,
hub::HUB,
resource::BufferUsageFlags,
track::{Stitch, TrackerSet},
BindGroupId, BufferId, CommandBuffer, CommandBufferId, RenderPassId, RenderPipelineId, Stored,
};

use hal::command::RawCommandBuffer;

use std::{iter, slice};


pub struct RenderPass<B: hal::Backend> {
raw: B::CommandBuffer,
cmb_id: Stored<CommandBufferId>,
Expand Down
16 changes: 9 additions & 7 deletions wgpu-native/src/command/transfer.rs
Original file line number Diff line number Diff line change
@@ -1,16 +1,18 @@
use crate::conv;
use crate::device::{all_buffer_stages, all_image_stages};
use crate::hub::HUB;
use crate::resource::TexturePlacement;
use crate::swap_chain::SwapChainLink;
use crate::{
conv,
device::{all_buffer_stages, all_image_stages},
hub::HUB,
resource::TexturePlacement,
swap_chain::SwapChainLink,
BufferId, BufferUsageFlags, CommandBufferId, Extent3d, Origin3d, TextureId, TextureUsageFlags,
};

use copyless::VecHelper as _;
use hal::command::RawCommandBuffer;

use std::iter;


const BITS_PER_BYTE: u32 = 8;

#[repr(C)]
Expand Down Expand Up @@ -130,7 +132,7 @@ pub extern "C" fn wgpu_command_buffer_copy_buffer_to_texture(
});

if let TexturePlacement::SwapChain(ref link) = dst_texture.placement {
cmb.swap_chain_links.push(SwapChainLink {
cmb.swap_chain_links.alloc().init(SwapChainLink {
swap_chain_id: link.swap_chain_id.clone(),
epoch: *link.epoch.lock(),
image_index: link.image_index,
Expand Down Expand Up @@ -306,7 +308,7 @@ pub extern "C" fn wgpu_command_buffer_copy_texture_to_texture(
});

if let TexturePlacement::SwapChain(ref link) = dst_texture.placement {
cmb.swap_chain_links.push(SwapChainLink {
cmb.swap_chain_links.alloc().init(SwapChainLink {
swap_chain_id: link.swap_chain_id.clone(),
epoch: *link.epoch.lock(),
image_index: link.image_index,
Expand Down
6 changes: 5 additions & 1 deletion wgpu-native/src/conv.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,8 @@
use crate::{binding_model, command, pipeline, resource, Color, Extent3d, Origin3d};
use crate::{
binding_model, command, pipeline, resource,
Color, Extent3d, Origin3d,
};


pub fn map_buffer_usage(
usage: resource::BufferUsageFlags,
Expand Down
Loading

0 comments on commit dfa126c

Please sign in to comment.