pub struct Surface { /* private fields */ }vulkan only.Implementations§
Source§impl Surface
impl Surface
Sourcepub unsafe fn raw_native_handle(&self) -> Option<SurfaceKHR>
pub unsafe fn raw_native_handle(&self) -> Option<SurfaceKHR>
Returns the raw Vulkan surface handle.
Returns None if the surface is a DXGI surface.
Sourcepub fn raw_native_swapchain(&self) -> Option<SwapchainKHR>
pub fn raw_native_swapchain(&self) -> Option<SwapchainKHR>
Get the raw Vulkan swapchain associated with this surface.
Returns None if the surface is not configured or if the swapchain
is a DXGI swapchain.
Sourcepub fn set_next_present_time(&self, present_timing: PresentTimeGOOGLE)
pub fn set_next_present_time(&self, present_timing: PresentTimeGOOGLE)
Set the present timing information which will be used for the next presentation of this surface, using VK_GOOGLE_display_timing.
This can be used to give an id to presentations, for future use of vk::PastPresentationTimingGOOGLE.
Note that wgpu-hal does not provide a way to use that API - you should manually access this through ash.
This can also be used to add a “not before” timestamp to the presentation.
The exact semantics of the fields are also documented in the specification for the extension.
§Panics
- If the surface hasn’t been configured.
- If the surface has been configured for a DXGI swapchain.
- If the device doesn’t have the VK_GOOGLE_display_timing extension enabled.
Sourcepub unsafe fn set_next_present_chain(&self, chain: *mut c_void)
pub unsafe fn set_next_present_chain(&self, chain: *mut c_void)
Set a pNext chain of extension structs to be attached to the vk::PresentInfoKHR
of the next presentation of this surface.
This supports presentation extensions that wgpu-hal has no dedicated support
for, such as VK_NV_present_metering. The corresponding device extension must be
enabled at device creation, e.g. with
Adapter::open_with_callback().
The chain is consumed by the next presentation: it replaces any chain set by a previous call that hasn’t been presented yet, and is discarded unread if the surface is reconfigured first.
§Safety
chainmust point to a validpNextchain of structs that can extendvk::PresentInfoKHR, whose extensions are enabled on the device.- The chain must stay valid, and must not be read or written, until the next presentation of this surface completes or the surface is reconfigured. Fields the driver wrote during presentation may be read afterwards.
§Panics
- If the surface hasn’t been configured.
- If the surface has been configured for a DXGI swapchain.
Sourcepub unsafe fn set_next_swapchain_create_chain(&self, chain: *mut c_void)
pub unsafe fn set_next_swapchain_create_chain(&self, chain: *mut c_void)
Set a pNext chain of extension structs to attach to the
vk::SwapchainCreateInfoKHR used by the next configuration of this surface.
This supports swapchain extensions that wgpu-hal has no dedicated support
for. One example is VkSwapchainLatencyCreateInfoNV from VK_NV_low_latency2.
The device extension itself must be enabled at device creation, for example
with Adapter::open_with_callback().
The next configuration consumes the chain. A later call replaces a chain that hasn’t been consumed yet. If the surface is dropped first, the chain is discarded unread. Every configuration creates a new swapchain, so you must set the chain again before each configuration, including on resize.
§Safety
chainmust point to a validpNextchain of structs that can extendvk::SwapchainCreateInfoKHR. The extensions in the chain must be enabled on the device the surface is configured with.- The chain must stay valid until the configuration that consumes it returns or the surface is dropped. Don’t read or write the chain during that time. Fields the driver wrote during swapchain creation may be read afterwards.
§Panics
- If the surface isn’t a native Vulkan surface, such as a DXGI surface.
Trait Implementations§
Source§impl DynResource for Surface
impl DynResource for Surface
Source§impl Surface for Surface
impl Surface for Surface
type A = Api
Source§unsafe fn configure(
&self,
device: &Device,
config: &SurfaceConfiguration,
) -> Result<(), SurfaceError>
unsafe fn configure( &self, device: &Device, config: &SurfaceConfiguration, ) -> Result<(), SurfaceError>
Source§unsafe fn unconfigure(&self, device: &Device)
unsafe fn unconfigure(&self, device: &Device)
Source§unsafe fn acquire_texture(
&self,
timeout: Option<Duration>,
fence: &Fence,
) -> Result<AcquiredSurfaceTexture<Api>, SurfaceError>
unsafe fn acquire_texture( &self, timeout: Option<Duration>, fence: &Fence, ) -> Result<AcquiredSurfaceTexture<Api>, SurfaceError>
self, for the caller to draw on. Read more