Skip to content

Persistent Metal swapchain #2169

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 6 commits into from
Jun 23, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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