C Specification

To create a VkSurfaceKHR object for a Win32 window, call:

// Provided by VK_KHR_win32_surface
VkResult vkCreateWin32SurfaceKHR(
    VkInstance                                  instance,
    const VkWin32SurfaceCreateInfoKHR*          pCreateInfo,
    const VkAllocationCallbacks*                pAllocator,
    VkSurfaceKHR*                               pSurface);

Parameters

  • instance is the instance to associate the surface with.

  • pCreateInfo is a pointer to a VkWin32SurfaceCreateInfoKHR structure containing parameters affecting the creation of the surface object.

  • pAllocator is the allocator used for host memory allocated for the surface object when there is no more specific allocator available (see Memory Allocation).

  • pSurface is a pointer to a VkSurfaceKHR handle in which the created surface object is returned.

Description

Valid Usage (Implicit)
  • VUID-vkCreateWin32SurfaceKHR-instance-parameter
    instance must be a valid VkInstance handle

  • VUID-vkCreateWin32SurfaceKHR-pCreateInfo-parameter
    pCreateInfo must be a valid pointer to a valid VkWin32SurfaceCreateInfoKHR structure

  • VUID-vkCreateWin32SurfaceKHR-pAllocator-parameter
    If pAllocator is not NULL, pAllocator must be a valid pointer to a valid VkAllocationCallbacks structure

  • VUID-vkCreateWin32SurfaceKHR-pSurface-parameter
    pSurface must be a valid pointer to a VkSurfaceKHR handle

Return Codes
On success, this command returns
  • VK_SUCCESS

On failure, this command returns
  • VK_ERROR_OUT_OF_HOST_MEMORY

  • VK_ERROR_OUT_OF_DEVICE_MEMORY

Some Vulkan functions may call the SendMessage system API when interacting with a VkSurfaceKHR through a VkSwapchainKHR. In a multithreaded environment, calling SendMessage from a thread that is not the thread associated with pCreateInfo::hwnd will block until the application has processed the window message. Thus, applications should either call these Vulkan functions on the message pump thread, or make sure their message pump is actively running. Failing to do so may result in deadlocks.

The functions subject to this requirement are:

See Also

Document Notes

For more information, see the Vulkan Specification

This page is extracted from the Vulkan Specification. Fixes and changes should be made to the Specification, not directly.

Copyright 2014-2024 The Khronos Group Inc.

SPDX-License-Identifier: CC-BY-4.0