Skip to content

Commit

Permalink
Update to latest rendy with gfx-0.4
Browse files Browse the repository at this point in the history
  • Loading branch information
kvark committed Oct 28, 2019
1 parent b71fc33 commit 271c709
Show file tree
Hide file tree
Showing 7 changed files with 170 additions and 131 deletions.
239 changes: 135 additions & 104 deletions Cargo.lock

Large diffs are not rendered by default.

21 changes: 11 additions & 10 deletions wgpu-native/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -28,24 +28,25 @@ bitflags = "1.0"
copyless = "0.1"
lazy_static = { version = "1.1.0", optional = true }
log = "0.4"
hal = { package = "gfx-hal", git = "https://github.com/gfx-rs/gfx", rev = "3d5db15661127c8cad8d85522a68ec36c82f6e69" }
gfx-backend-empty = { git = "https://github.com/gfx-rs/gfx", rev = "3d5db15661127c8cad8d85522a68ec36c82f6e69" }
hal = { package = "gfx-hal", git = "https://github.com/gfx-rs/gfx", rev = "46386475f7e823e807ec984c372ffe04dcc0a22b" }
gfx-auxil = { git = "https://github.com/gfx-rs/gfx", rev = "46386475f7e823e807ec984c372ffe04dcc0a22b" }
gfx-backend-empty = { git = "https://github.com/gfx-rs/gfx", rev = "46386475f7e823e807ec984c372ffe04dcc0a22b" }
parking_lot = "0.9"
raw-window-handle = { version = "0.3", optional = true }
rendy-memory = { git = "https://github.com/amethyst/rendy", rev = "e8ffcabc2bc74fbb282d4f71fa55c28d0ec31c86" }
rendy-descriptor = { git = "https://github.com/amethyst/rendy", rev = "e8ffcabc2bc74fbb282d4f71fa55c28d0ec31c86" }
rendy-memory = { git = "https://github.com/amethyst/rendy", rev = "948ee05f7b2d129f2f1b9321c87077dd766d9672" }
rendy-descriptor = { git = "https://github.com/amethyst/rendy", rev = "948ee05f7b2d129f2f1b9321c87077dd766d9672" }
serde = { version = "1.0", features = ["serde_derive"], optional = true }
smallvec = "0.6"
vec_map = "0.8"

[target.'cfg(any(target_os = "ios", target_os = "macos"))'.dependencies]
gfx-backend-metal = { git = "https://github.com/gfx-rs/gfx", rev = "3d5db15661127c8cad8d85522a68ec36c82f6e69" }
gfx-backend-vulkan = { git = "https://github.com/gfx-rs/gfx", rev = "3d5db15661127c8cad8d85522a68ec36c82f6e69", optional = true }
gfx-backend-metal = { git = "https://github.com/gfx-rs/gfx", rev = "46386475f7e823e807ec984c372ffe04dcc0a22b" }
gfx-backend-vulkan = { git = "https://github.com/gfx-rs/gfx", rev = "46386475f7e823e807ec984c372ffe04dcc0a22b", optional = true }

[target.'cfg(all(unix, not(target_os = "ios"), not(target_os = "macos")))'.dependencies]
gfx-backend-vulkan = { git = "https://github.com/gfx-rs/gfx", rev = "3d5db15661127c8cad8d85522a68ec36c82f6e69", features = ["x11"] }
gfx-backend-vulkan = { git = "https://github.com/gfx-rs/gfx", rev = "46386475f7e823e807ec984c372ffe04dcc0a22b", features = ["x11"] }

[target.'cfg(windows)'.dependencies]
gfx-backend-dx12 = { git = "https://github.com/gfx-rs/gfx", rev = "3d5db15661127c8cad8d85522a68ec36c82f6e69" }
gfx-backend-dx11 = { git = "https://github.com/gfx-rs/gfx", rev = "3d5db15661127c8cad8d85522a68ec36c82f6e69" }
gfx-backend-vulkan = { git = "https://github.com/gfx-rs/gfx", rev = "3d5db15661127c8cad8d85522a68ec36c82f6e69" }
gfx-backend-dx12 = { git = "https://github.com/gfx-rs/gfx", rev = "46386475f7e823e807ec984c372ffe04dcc0a22b" }
gfx-backend-dx11 = { git = "https://github.com/gfx-rs/gfx", rev = "46386475f7e823e807ec984c372ffe04dcc0a22b" }
gfx-backend-vulkan = { git = "https://github.com/gfx-rs/gfx", rev = "46386475f7e823e807ec984c372ffe04dcc0a22b" }
8 changes: 6 additions & 2 deletions wgpu-native/src/command/allocator.rs
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,9 @@ struct CommandPool<B: hal::Backend> {
impl<B: hal::Backend> CommandPool<B> {
fn allocate(&mut self) -> B::CommandBuffer {
if self.available.is_empty() {
let extra = self.raw.allocate_vec(20, hal::command::Level::Primary);
let extra = unsafe {
self.raw.allocate_vec(20, hal::command::Level::Primary)
};
self.available.extend(extra);
}

Expand Down Expand Up @@ -111,7 +113,9 @@ impl<B: hal::Backend> CommandAllocator<B> {
let pool = inner.pools.get_mut(&cmd_buf.recorded_thread_id).unwrap();

if pool.available.is_empty() {
let extra = pool.raw.allocate_vec(20, hal::command::Level::Primary);
let extra = unsafe {
pool.raw.allocate_vec(20, hal::command::Level::Primary)
};
pool.available.extend(extra);
}

Expand Down
6 changes: 3 additions & 3 deletions wgpu-native/src/conv.rs
Original file line number Diff line number Diff line change
Expand Up @@ -138,9 +138,9 @@ pub fn map_extent(extent: Extent3d) -> hal::image::Extent {
}
}

pub fn map_primitive_topology(primitive_topology: pipeline::PrimitiveTopology) -> hal::Primitive {
pub fn map_primitive_topology(primitive_topology: pipeline::PrimitiveTopology) -> hal::pso::Primitive {
use crate::pipeline::PrimitiveTopology as Pt;
use hal::Primitive as H;
use hal::pso::Primitive as H;
match primitive_topology {
Pt::PointList => H::PointList,
Pt::LineList => H::LineList,
Expand Down Expand Up @@ -512,7 +512,7 @@ pub fn map_buffer_state(usage: resource::BufferUsage) -> hal::buffer::State {
access |= A::VERTEX_BUFFER_READ;
}
if usage.contains(W::UNIFORM) {
access |= A::CONSTANT_BUFFER_READ | A::SHADER_READ;
access |= A::UNIFORM_READ | A::SHADER_READ;
}
if usage.contains(W::STORAGE) {
access |= A::SHADER_WRITE;
Expand Down
19 changes: 11 additions & 8 deletions wgpu-native/src/device.rs
Original file line number Diff line number Diff line change
Expand Up @@ -48,9 +48,9 @@ use crate::{gfx_select, hub::GLOBAL};

use arrayvec::ArrayVec;
use copyless::VecHelper as _;
use gfx_auxil::FastHashMap;
use hal::{
self,
backend::FastHashMap,
command::CommandBuffer as _,
device::Device as _,
queue::CommandQueue as _,
Expand Down Expand Up @@ -1090,7 +1090,7 @@ pub fn device_create_sampler<B: GfxBackend>(
let (device_guard, mut token) = hub.devices.read(&mut token);
let device = &device_guard[device_id];

let info = hal::image::SamplerInfo {
let info = hal::image::SamplerDesc {
min_filter: conv::map_filter(desc.min_filter),
mag_filter: conv::map_filter(desc.mag_filter),
mip_filter: conv::map_filter(desc.mipmap_filter),
Expand All @@ -1099,8 +1099,8 @@ pub fn device_create_sampler<B: GfxBackend>(
conv::map_wrap(desc.address_mode_v),
conv::map_wrap(desc.address_mode_w),
),
lod_bias: 0.0.into(),
lod_range: desc.lod_min_clamp.into() .. desc.lod_max_clamp.into(),
lod_bias: hal::image::Lod(0.0),
lod_range: hal::image::Lod(desc.lod_min_clamp) .. hal::image::Lod(desc.lod_max_clamp),
comparison: if desc.compare_function == resource::CompareFunction::Always {
None
} else {
Expand All @@ -1112,7 +1112,7 @@ pub fn device_create_sampler<B: GfxBackend>(
};

let sampler = resource::Sampler {
raw: unsafe { device.raw.create_sampler(info).unwrap() },
raw: unsafe { device.raw.create_sampler(&info).unwrap() },
device_id: Stored {
value: device_id,
ref_count: device.life_guard.ref_count.clone(),
Expand Down Expand Up @@ -1774,7 +1774,8 @@ pub fn device_create_render_pipeline<B: GfxBackend>(

let input_assembler = hal::pso::InputAssemblerDesc {
primitive: conv::map_primitive_topology(desc.primitive_topology),
primitive_restart: hal::pso::PrimitiveRestart::Disabled, // TODO
with_adjacency: false,
restart_index: None, //TODO
};

let blender = hal::pso::BlendDesc {
Expand Down Expand Up @@ -2055,11 +2056,13 @@ pub fn device_create_swap_chain<B: GfxBackend>(
let device = &device_guard[device_id];
let surface = &mut surface_guard[surface_id];

let (caps, formats, _present_modes) = {
let (caps, formats) = {
let suf = B::get_surface_mut(surface);
let adapter = &adapter_guard[device.adapter_id];
assert!(suf.supports_queue_family(&adapter.raw.queue_families[0]));
suf.compatibility(&adapter.raw.physical_device)
let formats = suf.supported_formats(&adapter.raw.physical_device);
let caps = suf.capabilities(&adapter.raw.physical_device);
(caps, formats)
};
let num_frames = swap_chain::DESIRED_NUM_FRAMES
.max(*caps.image_count.start())
Expand Down
6 changes: 3 additions & 3 deletions wgpu-native/src/swap_chain.rs
Original file line number Diff line number Diff line change
Expand Up @@ -97,10 +97,10 @@ impl SwapChainDescriptor {
);
//TODO: check for supported
config.image_usage = conv::map_texture_usage(self.usage, hal::format::Aspects::COLOR);
config.composite_alpha = hal::window::CompositeAlpha::OPAQUE;
config.composite_alpha_mode = hal::window::CompositeAlphaMode::OPAQUE;
config.present_mode = match self.present_mode {
PresentMode::NoVsync => hal::window::PresentMode::Immediate,
PresentMode::Vsync => hal::window::PresentMode::Fifo,
PresentMode::NoVsync => hal::window::PresentMode::IMMEDIATE,
PresentMode::Vsync => hal::window::PresentMode::FIFO,
};
config
}
Expand Down
2 changes: 1 addition & 1 deletion wgpu-native/src/track/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ use crate::{
TypedId,
};

use hal::backend::FastHashMap;
use gfx_auxil::FastHashMap;

use std::{
borrow::Borrow,
Expand Down

0 comments on commit 271c709

Please sign in to comment.