Skip to content

Commit

Permalink
Merge #2169
Browse files Browse the repository at this point in the history
2169: Persistent Metal swapchain r=grovesNL a=kvark

Includes #2164
Fixes #2168
Fixes #2143
Removes deferred image resolution (yay!), and also renames some of the outdated concepts.
We have no flickering, and proper frame sync now.

PR checklist:
- [x] `make` succeeds (on *nix)
- [x] `make reftests` succeeds
- [x] tested examples with the following backends:


Co-authored-by: Dzmitry Malyshau <kvarkus@gmail.com>
  • Loading branch information
bors[bot] and kvark committed Jun 23, 2018
2 parents 1f3692f + 1f4cbc4 commit f2f7c5d
Show file tree
Hide file tree
Showing 21 changed files with 423 additions and 386 deletions.
5 changes: 3 additions & 2 deletions examples/quad/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -463,8 +463,8 @@ fn main() {

device.reset_fence(&frame_fence);
command_pool.reset();
let frame: hal::FrameImage = {
match swap_chain.acquire_frame(FrameSync::Semaphore(&mut frame_semaphore)) {
let frame: hal::SwapImageIndex = {
match swap_chain.acquire_image(FrameSync::Semaphore(&mut frame_semaphore)) {
Ok(i) => i,
Err(_) => {
recreate_swapchain = true;
Expand Down Expand Up @@ -599,6 +599,7 @@ fn swapchain_stuff(
println!("Surface format: {:?}", format);
let swap_config = SwapchainConfig::new()
.with_color(format)
.with_image_count(caps.image_count.start)
.with_image_usage(i::Usage::COLOR_ATTACHMENT);
let (swap_chain, backbuffer) = device.create_swapchain(surface, swap_config, None, &extent);

Expand Down
6 changes: 3 additions & 3 deletions src/backend/dx11/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ extern crate winit;
extern crate wio;

use hal::{buffer, command, error, format, image, memory, query, pso, Features, Limits, QueueType};
use hal::{DrawCount, FrameImage, IndexCount, InstanceCount, VertexCount, VertexOffset, WorkGroupCount};
use hal::{DrawCount, SwapImageIndex, IndexCount, InstanceCount, VertexCount, VertexOffset, WorkGroupCount};
use hal::queue::{QueueFamilyId, Queues};
use hal::backend::RawQueueGroup;
use hal::range::RangeArg;
Expand Down Expand Up @@ -639,7 +639,7 @@ unsafe impl Send for Swapchain { }
unsafe impl Sync for Swapchain { }

impl hal::Swapchain<Backend> for Swapchain {
fn acquire_frame(&mut self, _sync: hal::FrameSync<Backend>) -> Result<hal::FrameImage, ()> {
fn acquire_image(&mut self, _sync: hal::FrameSync<Backend>) -> Result<hal::SwapImageIndex, ()> {
// TODO: non-`_DISCARD` swap effects have more than one buffer, `FLIP`
// effects are dxgi 1.3 (w10+?) in which case there is
// `GetCurrentBackBufferIndex()` on the swapchain
Expand Down Expand Up @@ -681,7 +681,7 @@ impl hal::queue::RawCommandQueue<Backend> for CommandQueue {

fn present<IS, S, IW>(&mut self, swapchains: IS, _wait_semaphores: IW) -> Result<(), ()>
where
IS: IntoIterator<Item = (S, FrameImage)>,
IS: IntoIterator<Item = (S, SwapImageIndex)>,
S: Borrow<Swapchain>,
IW: IntoIterator,
IW::Item: Borrow<Semaphore>,
Expand Down
4 changes: 2 additions & 2 deletions src/backend/dx12/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ mod pool;
mod root_constants;
mod window;

use hal::{error, format as f, image, memory, Features, FrameImage, Limits, QueueType};
use hal::{error, format as f, image, memory, Features, SwapImageIndex, Limits, QueueType};
use hal::queue::{QueueFamilyId, Queues};
use descriptors_cpu::DescriptorCpuPool;

Expand Down Expand Up @@ -468,7 +468,7 @@ impl hal::queue::RawCommandQueue<Backend> for CommandQueue {

fn present<IS, S, IW>(&mut self, swapchains: IS, _wait_semaphores: IW) -> Result<(), ()>
where
IS: IntoIterator<Item = (S, FrameImage)>,
IS: IntoIterator<Item = (S, SwapImageIndex)>,
S: Borrow<window::Swapchain>,
IW: IntoIterator,
IW::Item: Borrow<native::Semaphore>,
Expand Down
2 changes: 1 addition & 1 deletion src/backend/dx12/src/window.rs
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,7 @@ pub struct Swapchain {
}

impl hal::Swapchain<Backend> for Swapchain {
fn acquire_frame(&mut self, _sync: hal::FrameSync<Backend>) -> Result<hal::FrameImage, ()> {
fn acquire_image(&mut self, _sync: hal::FrameSync<Backend>) -> Result<hal::SwapImageIndex, ()> {
// TODO: sync

if false {
Expand Down
4 changes: 2 additions & 2 deletions src/backend/empty/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,7 @@ impl queue::RawCommandQueue<Backend> for RawCommandQueue {

fn present<IS, S, IW>(&mut self, _: IS, _: IW) -> Result<(), ()>
where
IS: IntoIterator<Item = (S, hal::FrameImage)>,
IS: IntoIterator<Item = (S, hal::SwapImageIndex)>,
S: Borrow<Swapchain>,
IW: IntoIterator,
IW::Item: Borrow<()>,
Expand Down Expand Up @@ -785,7 +785,7 @@ impl hal::Surface<Backend> for Surface {
/// Dummy swapchain.
pub struct Swapchain;
impl hal::Swapchain<Backend> for Swapchain {
fn acquire_frame(&mut self, _: hal::FrameSync<Backend>) -> Result<hal::FrameImage, ()> {
fn acquire_image(&mut self, _: hal::FrameSync<Backend>) -> Result<hal::SwapImageIndex, ()> {
unimplemented!()
}
}
Expand Down
2 changes: 1 addition & 1 deletion src/backend/gl/src/queue.rs
Original file line number Diff line number Diff line change
Expand Up @@ -722,7 +722,7 @@ impl hal::queue::RawCommandQueue<Backend> for CommandQueue {
#[cfg(feature = "glutin")]
fn present<IS, S, IW>(&mut self, swapchains: IS, _wait_semaphores: IW) -> Result<(), ()>
where
IS: IntoIterator<Item = (S, hal::FrameImage)>,
IS: IntoIterator<Item = (S, hal::SwapImageIndex)>,
S: Borrow<window::glutin::Swapchain>,
IW: IntoIterator,
IW::Item: Borrow<native::Semaphore>,
Expand Down
2 changes: 1 addition & 1 deletion src/backend/gl/src/window/glutin.rs
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ pub struct Swapchain {
}

impl hal::Swapchain<B> for Swapchain {
fn acquire_frame(&mut self, _sync: hal::FrameSync<B>) -> Result<hal::FrameImage, ()> {
fn acquire_image(&mut self, _sync: hal::FrameSync<B>) -> Result<hal::SwapImageIndex, ()> {
// TODO: sync
Ok(0)
}
Expand Down
Loading

0 comments on commit f2f7c5d

Please sign in to comment.