Restore Surface::from_display_mode

This commit is contained in:
Pierre Krieger 2016-11-18 09:02:56 +01:00
parent 9a32bd1baa
commit 0161dc3c93
2 changed files with 14 additions and 7 deletions

View File

@ -34,6 +34,7 @@ use vk;
/// ? /// ?
// TODO: plane capabilities // TODO: plane capabilities
// TODO: store properties in the instance?
pub struct DisplayPlane { pub struct DisplayPlane {
instance: Arc<Instance>, instance: Arc<Instance>,
physical_device: usize, physical_device: usize,
@ -112,6 +113,12 @@ impl DisplayPlane {
PhysicalDevice::from_index(&self.instance, self.physical_device).unwrap() PhysicalDevice::from_index(&self.instance, self.physical_device).unwrap()
} }
/// Returns the index of the plane.
#[inline]
pub fn index(&self) -> u32 {
self.index
}
/// Returns true if this plane supports the given display. /// Returns true if this plane supports the given display.
#[inline] #[inline]
pub fn supports(&self, display: &Display) -> bool { pub fn supports(&self, display: &Display) -> bool {

View File

@ -56,8 +56,7 @@ impl Surface {
pub fn from_display_mode(display_mode: &DisplayMode, plane: &DisplayPlane) pub fn from_display_mode(display_mode: &DisplayMode, plane: &DisplayPlane)
-> Result<Arc<Surface>, SurfaceCreationError> -> Result<Arc<Surface>, SurfaceCreationError>
{ {
unimplemented!() // TODO: if !display_mode.display().physical_device().instance().loaded_extensions().khr_display {
/*if !display_mode.display().physical_device().instance().loaded_extensions().khr_display {
return Err(SurfaceCreationError::MissingExtension { name: "VK_KHR_display" }); return Err(SurfaceCreationError::MissingExtension { name: "VK_KHR_display" });
} }
@ -74,14 +73,14 @@ impl Surface {
pNext: ptr::null(), pNext: ptr::null(),
flags: 0, // reserved flags: 0, // reserved
displayMode: display_mode.internal_object(), displayMode: display_mode.internal_object(),
planeIndex: plane.index, planeIndex: plane.index(),
planeStackIndex: plane.properties.currentStackIndex, planeStackIndex: 0, // FIXME: plane.properties.currentStackIndex,
transform: vk::SURFACE_TRANSFORM_IDENTITY_BIT_KHR, // TODO: let user choose transform: vk::SURFACE_TRANSFORM_IDENTITY_BIT_KHR, // TODO: let user choose
globalAlpha: 0.0, // TODO: let user choose globalAlpha: 0.0, // TODO: let user choose
alphaMode: vk::DISPLAY_PLANE_ALPHA_OPAQUE_BIT_KHR, // TODO: let user choose alphaMode: vk::DISPLAY_PLANE_ALPHA_OPAQUE_BIT_KHR, // TODO: let user choose
imageExtent: vk::Extent2D { // TODO: let user choose imageExtent: vk::Extent2D { // TODO: let user choose
width: display_mode.parameters.visibleRegion.width, width: display_mode.visible_region()[0],
height: display_mode.parameters.visibleRegion.height, height: display_mode.visible_region()[1],
}, },
}; };
@ -94,7 +93,8 @@ impl Surface {
Ok(Arc::new(Surface { Ok(Arc::new(Surface {
instance: instance.clone(), instance: instance.clone(),
surface: surface, surface: surface,
}))*/ has_swapchain: AtomicBool::new(false),
}))
} }
/// Creates a `Surface` from a Win32 window. /// Creates a `Surface` from a Win32 window.