Class KHRSurface



  • public class KHRSurface
    extends java.lang.Object
    The VK_KHR_surface extension is an instance extension. It introduces VkSurfaceKHR objects, which abstract native platform surface or window objects for use with Vulkan. It also provides a way to determine whether a queue family in a physical device supports presenting to particular surface.

    Separate extensions for each each platform provide the mechanisms for creating VkSurfaceKHRs, but once created they may be used in this and other platform-independent extensions, in particular the VK_KHR_swapchain extension.

    • Field Detail

      • VK_KHR_SURFACE_SPEC_VERSION

        public static final int VK_KHR_SURFACE_SPEC_VERSION
        The extension specification version.
        See Also:
        Constant Field Values
      • VK_KHR_SURFACE_EXTENSION_NAME

        public static final java.lang.String VK_KHR_SURFACE_EXTENSION_NAME
        The extension name.
        See Also:
        Constant Field Values
      • VK_ERROR_SURFACE_LOST_KHR

        public static final int VK_ERROR_SURFACE_LOST_KHR
        A surface is no longer available.
        See Also:
        Constant Field Values
      • VK_ERROR_NATIVE_WINDOW_IN_USE_KHR

        public static final int VK_ERROR_NATIVE_WINDOW_IN_USE_KHR
        The requested window is already connected to a VkSurfaceKHR, or to some other non-Vulkan API.
        See Also:
        Constant Field Values
      • VK_COLOR_SPACE_SRGB_NONLINEAR_KHR

        public static final int VK_COLOR_SPACE_SRGB_NONLINEAR_KHR
        The presentation engine supports the sRGB colorspace.
        See Also:
        Constant Field Values
      • VK_PRESENT_MODE_IMMEDIATE_KHR

        public static final int VK_PRESENT_MODE_IMMEDIATE_KHR
        The presentation engine does not wait for a vertical blanking period to update the current image, meaning this mode may result in visible tearing. No internal queuing of presentation requests is needed, as the requests are applied immediately.
        See Also:
        Constant Field Values
      • VK_PRESENT_MODE_MAILBOX_KHR

        public static final int VK_PRESENT_MODE_MAILBOX_KHR
        The presentation engine waits for the next vertical blanking period to update the current image. Tearing cannot be observed. An internal single-entry queue is used to hold pending presentation requests. If the queue is full when a new presentation request is received, the new request replaces the existing entry, and any images associated with the prior entry become available for re-use by the application. One request is removed from the queue and processed during each vertical blanking period in which the queue is non-empty.
        See Also:
        Constant Field Values
      • VK_PRESENT_MODE_FIFO_KHR

        public static final int VK_PRESENT_MODE_FIFO_KHR
        The presentation engine waits for the next vertical blanking period to update the current image. Tearing cannot be observed. An internal queue containing (numSwapchainImages - 1) entries, where numSwapchainImages is the number of presentable images in the swapchain, is used to hold pending presentation requests. New requests are appended to the end of the queue, and one request is removed from the beginning of the queue and processed during each vertical blanking period in which the queue is non-empty. This is the only value of presentMode that is required to be supported.
        See Also:
        Constant Field Values
      • VK_PRESENT_MODE_FIFO_RELAXED_KHR

        public static final int VK_PRESENT_MODE_FIFO_RELAXED_KHR
        The presentation engine waits for the next vertical blanking period to update the current image. If a vertical blanking period has already passed since the last update of the current image then the presentation engine does not wait for another vertical blanking period for the update, meaning this mode may result in visible tearing in this case. An internal queue containing numSwapchainImages − 1 entries, where numSwapchainImages is the number of presentable images in the swapchain, is used to hold pending presentation requests. New requests are appended to the end of the queue, and one request is removed from the beginning of the queue and processed during or after each vertical blanking period in which the queue is non-empty.
        See Also:
        Constant Field Values
      • VK_SURFACE_TRANSFORM_IDENTITY_BIT_KHR

        public static final int VK_SURFACE_TRANSFORM_IDENTITY_BIT_KHR
        The image content is presented without being transformed.
        See Also:
        Constant Field Values
      • VK_SURFACE_TRANSFORM_ROTATE_90_BIT_KHR

        public static final int VK_SURFACE_TRANSFORM_ROTATE_90_BIT_KHR
        The image content is rotated 90 degrees clockwise.
        See Also:
        Constant Field Values
      • VK_SURFACE_TRANSFORM_ROTATE_180_BIT_KHR

        public static final int VK_SURFACE_TRANSFORM_ROTATE_180_BIT_KHR
        The image content is rotated 180 degrees clockwise.
        See Also:
        Constant Field Values
      • VK_SURFACE_TRANSFORM_ROTATE_270_BIT_KHR

        public static final int VK_SURFACE_TRANSFORM_ROTATE_270_BIT_KHR
        The image content is rotated 270 degrees clockwise.
        See Also:
        Constant Field Values
      • VK_SURFACE_TRANSFORM_HORIZONTAL_MIRROR_BIT_KHR

        public static final int VK_SURFACE_TRANSFORM_HORIZONTAL_MIRROR_BIT_KHR
        The image content is mirrored horizontally.
        See Also:
        Constant Field Values
      • VK_SURFACE_TRANSFORM_HORIZONTAL_MIRROR_ROTATE_90_BIT_KHR

        public static final int VK_SURFACE_TRANSFORM_HORIZONTAL_MIRROR_ROTATE_90_BIT_KHR
        The image content is mirrored horizontally, then rotated 90 degrees clockwise.
        See Also:
        Constant Field Values
      • VK_SURFACE_TRANSFORM_HORIZONTAL_MIRROR_ROTATE_180_BIT_KHR

        public static final int VK_SURFACE_TRANSFORM_HORIZONTAL_MIRROR_ROTATE_180_BIT_KHR
        The image content is mirrored horizontally, then rotated 180 degrees clockwise.
        See Also:
        Constant Field Values
      • VK_SURFACE_TRANSFORM_HORIZONTAL_MIRROR_ROTATE_270_BIT_KHR

        public static final int VK_SURFACE_TRANSFORM_HORIZONTAL_MIRROR_ROTATE_270_BIT_KHR
        The image content is mirrored horizontally, then rotated 270 degrees clockwise.
        See Also:
        Constant Field Values
      • VK_SURFACE_TRANSFORM_INHERIT_BIT_KHR

        public static final int VK_SURFACE_TRANSFORM_INHERIT_BIT_KHR
        The presentation transform is not specified, and is instead determined by platform-specific considerations and mechanisms outside Vulkan.
        See Also:
        Constant Field Values
      • VK_COMPOSITE_ALPHA_OPAQUE_BIT_KHR

        public static final int VK_COMPOSITE_ALPHA_OPAQUE_BIT_KHR
        The alpha channel, if it exists, of the images is ignored in the compositing process. Instead, the image is treated as if it has a constant alpha of 1.0.
        See Also:
        Constant Field Values
      • VK_COMPOSITE_ALPHA_PRE_MULTIPLIED_BIT_KHR

        public static final int VK_COMPOSITE_ALPHA_PRE_MULTIPLIED_BIT_KHR
        The alpha channel, if it exists, of the images is respected in the compositing process. The non-alpha channels of the image are expected to already be multiplied by the alpha channel by the application.
        See Also:
        Constant Field Values
      • VK_COMPOSITE_ALPHA_POST_MULTIPLIED_BIT_KHR

        public static final int VK_COMPOSITE_ALPHA_POST_MULTIPLIED_BIT_KHR
        The alpha channel, if it exists, of the images is respected in the compositing process. The non-alpha channels of the image are not expected to already be multiplied by the alpha channel by the application; instead, the compositor will multiply the non-alpha channels of the image by the alpha channel during compositing.
        See Also:
        Constant Field Values
      • VK_COMPOSITE_ALPHA_INHERIT_BIT_KHR

        public static final int VK_COMPOSITE_ALPHA_INHERIT_BIT_KHR
        The way in which the presentation engine treats the alpha channel in the images is unknown to the Vulkan API. Instead, the application is responsible for setting the composite alpha blending mode using native window system commands. If the application does not set the blending mode using native window system commands, then a platform-specific default will be used.
        See Also:
        Constant Field Values
    • Method Detail

      • vkDestroySurfaceKHR

        public static void vkDestroySurfaceKHR(VkInstance instance,
                                               long surface,
                                               VkAllocationCallbacks pAllocator)
        Destroys a VkSurfaceKHR object.

        Several WSI functions return ERROR_SURFACE_LOST_KHR if the surface becomes no longer available. After such an error, the surface (and any child swapchain, if one exists) should be destroyed, as there is no way to restore them to a not-lost state. Applications may attempt to create a new VkSurfaceKHR using the same native platform window object, but whether such re-creation will succeed is platform-dependent and may depend on the reason the surface became unavailable. A lost surface does not otherwise cause devices to be lost.

        Destroying a VkSurfaceKHR merely severs the connection between Vulkan and the native surface, and doesn’t imply destroying the native surface, closing a window, or similar behavior.

        Valid Usage
        • instance must be a valid VkInstance handle
        • If surface is not NULL_HANDLE, surface must be a valid VkSurfaceKHR handle
        • If pAllocator is not NULL, pAllocator must be a pointer to a valid VkAllocationCallbacks structure
        • If surface is a valid handle, it must have been created, allocated or retrieved from instance
        • All VkSwapchainKHR objects created for surface must have been destroyed prior to destroying surface
        • If VkAllocationCallbacks were provided when surface was created, a compatible set of callbacks must be provided here
        • If no VkAllocationCallbacks were provided when surface was created, pAllocator must be NULL
        Host Synchronization
        • Host access to surface must be externally synchronized
        Parameters:
        instance - the instance used to create the surface
        surface - the surface to destroy
        pAllocator - controls host memory allocation
      • vkGetPhysicalDeviceSurfaceSupportKHR

        public static int vkGetPhysicalDeviceSurfaceSupportKHR(VkPhysicalDevice physicalDevice,
                                                               int queueFamilyIndex,
                                                               long surface,
                                                               java.nio.IntBuffer pSupported)
        Determines whether a queue family of a physical device supports presentation to a given surface.
        Valid Usage
        • physicalDevice must be a valid VkPhysicalDevice handle
        • surface must be a valid VkSurfaceKHR handle
        • pSupported must be a pointer to a VkBool32 value
        • Each of physicalDevice and surface must have been created, allocated or retrieved from the same VkInstance
        • queueFamilyIndex must be less than pQueueFamilyPropertyCount returned by GetPhysicalDeviceQueueFamilyProperties for the given physicalDevice
        Parameters:
        physicalDevice - the physical device
        queueFamilyIndex - the queue family
        surface - the surface
        pSupported - a pointer to a VkBool32, which is set to TRUE to indicate support, and FALSE otherwise
      • vkGetPhysicalDeviceSurfaceCapabilitiesKHR

        public static int vkGetPhysicalDeviceSurfaceCapabilitiesKHR(VkPhysicalDevice physicalDevice,
                                                                    long surface,
                                                                    VkSurfaceCapabilitiesKHR pSurfaceCapabilities)
        Queries the basic capabilities of a surface, needed in order to create a swapchain.
        Valid Usage
        • physicalDevice must be a valid VkPhysicalDevice handle
        • surface must be a valid VkSurfaceKHR handle
        • pSurfaceCapabilities must be a pointer to a VkSurfaceCapabilitiesKHR structure
        • Each of physicalDevice and surface must have been created, allocated or retrieved from the same VkInstance
        Parameters:
        physicalDevice - the physical device that will be associated with the swapchain to be created
        surface - the surface that will be associated with the swapchain
        pSurfaceCapabilities - a pointer to an instance of the VkSurfaceCapabilitiesKHR structure that will be filled with information
      • vkGetPhysicalDeviceSurfaceFormatsKHR

        public static int vkGetPhysicalDeviceSurfaceFormatsKHR(VkPhysicalDevice physicalDevice,
                                                               long surface,
                                                               java.nio.IntBuffer pSurfaceFormatCount,
                                                               VkSurfaceFormatKHR.Buffer pSurfaceFormats)
        Queries the supported swapchain format-colorspace pairs for a surface.

        If pSurfaceFormats is NULL, then the number of format pairs supported for the given surface is returned in pSurfaceFormatCount. Otherwise, pSurfaceFormatCount must point to a variable set by the user to the number of elements in the pSurfaceFormats array, and on return the variable is overwritten with the number of structures actually written to pSurfaceFormats. If the value of pSurfaceFormatCount is less than the number of queue families supported, at most pSurfaceFormatCount structures will be written. If pSurfaceFormatCount is smaller than the number of format pairs supported for the given surface, INCOMPLETE will be returned instead of SUCCESS to indicate that not all the available values were returned.

        Valid Usage
        • physicalDevice must be a valid VkPhysicalDevice handle
        • surface must be a valid VkSurfaceKHR handle
        • pSurfaceFormatCount must be a pointer to a uint32_t value
        • If the value referenced by pSurfaceFormatCount is not 0, and pSurfaceFormats is not NULL, pSurfaceFormats must be a pointer to an array of pSurfaceFormatCount VkSurfaceFormatKHR structures
        • Each of physicalDevice and surface must have been created, allocated or retrieved from the same VkInstance
        Parameters:
        physicalDevice - the physical device that will be associated with the swapchain to be created
        surface - the surface that will be associated with the swapchain
        pSurfaceFormatCount - a pointer to an integer related to the number of format pairs available or queried
        pSurfaceFormats - either NULL or a pointer to an array of VkSurfaceFormatKHR structures
      • vkGetPhysicalDeviceSurfacePresentModesKHR

        public static int vkGetPhysicalDeviceSurfacePresentModesKHR(VkPhysicalDevice physicalDevice,
                                                                    long surface,
                                                                    java.nio.IntBuffer pPresentModeCount,
                                                                    java.nio.IntBuffer pPresentModes)
        Queries the supported presentation modes for a surface.

        If pPresentModes is NULL, then the number of presentation modes supported for the given surface is returned in pPresentModeCount. Otherwise, pPresentModeCount must point to a variable set by the user to the number of elements in the pPresentModes array, and on return the variable is overwritten with the number of structures actually written to pPresentModes. If the value of pPresentModeCount is less than the number of presentation modes supported, at most pPresentModeCount structures will be written. If pPresentModeCount is smaller than the number of presentation modes supported for the given surface, INCOMPLETE will be returned instead of SUCCESS to indicate that not all the available values were returned.

        Valid Usage
        • physicalDevice must be a valid VkPhysicalDevice handle
        • surface must be a valid VkSurfaceKHR handle
        • pPresentModeCount must be a pointer to a uint32_t value
        • If the value referenced by pPresentModeCount is not 0, and pPresentModes is not NULL, pPresentModes must be a pointer to an array of pPresentModeCount VkPresentModeKHR values
        • Each of physicalDevice and surface must have been created, allocated or retrieved from the same VkInstance
        Parameters:
        physicalDevice - the physical device that will be associated with the swapchain to be created
        surface - the surface that will be associated with the swapchain
        pPresentModeCount - a pointer to an integer related to the number of format pairs available or queried
        pPresentModes - either NULL or a pointer to an array of VkPresentModeKHR values