khr_swapchain

package
v2.2.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Apr 27, 2023 License: MIT Imports: 12 Imported by: 41

Documentation

Index

Constants

View Source
const (
	// ExtensionName is "VK_KHR_swapchain"
	//
	// https://registry.khronos.org/vulkan/specs/1.3-extensions/man/html/VK_KHR_swapchain.html
	ExtensionName string = C.VK_KHR_SWAPCHAIN_EXTENSION_NAME

	// ObjectTypeSwapchain specifies a Swapchain handle
	//
	// https://registry.khronos.org/vulkan/specs/1.3-extensions/man/html/VkObjectType.html
	ObjectTypeSwapchain core1_0.ObjectType = C.VK_OBJECT_TYPE_SWAPCHAIN_KHR

	// ImageLayoutPresentSrc must only be used for presenting a presentable Image for display.
	// A Swapchain object's Image must be transitioned to this layout before calling Extension.QueuePresent,
	// and must be transitioned away from this layout after calling Swapchain.AcquireNextImage
	//
	// https://registry.khronos.org/vulkan/specs/1.3-extensions/man/html/VkImageLayout.html
	ImageLayoutPresentSrc core1_0.ImageLayout = C.VK_IMAGE_LAYOUT_PRESENT_SRC_KHR

	// VKErrorOutOfDate indicates a Surface has changed in such a way that it is no longer cmopatible
	// with the Swapchain, and further presentation requests using the Swapchain will fail
	//
	// https://registry.khronos.org/vulkan/specs/1.3-extensions/man/html/VkResult.html
	VKErrorOutOfDate common.VkResult = C.VK_ERROR_OUT_OF_DATE_KHR
	// VKSuboptimal indicates a Swapchain no longer matches the Surface properties exactly, but can
	// still be used to present to the Surface successfully
	//
	// https://registry.khronos.org/vulkan/specs/1.3-extensions/man/html/VkResult.html
	VKSuboptimal common.VkResult = C.VK_SUBOPTIMAL_KHR
)

Variables

This section is empty.

Functions

This section is empty.

Types

type Extension

type Extension interface {
	// Driver is the Vulkan wrapper driver used by this Extension
	Driver() khr_swapchain_driver.Driver
	// APIVersion is the maximum Vulkan API version supported by this Extension. If it is at least Vulkan 1.1,
	// khr_swapchain1_1.PromoteExtension can be used to promote this to a khr_swapchain1_1.Extension
	APIVersion() common.APIVersion

	// CreateSwapchain creates a Swapchain
	//
	// device - The Device to create the Swapchain for
	//
	// allocation - Controls host memory allocation behavior
	//
	// options - Specifies the parameters of the created Swapchain
	//
	// https://registry.khronos.org/vulkan/specs/1.3-extensions/man/html/vkCreateSwapchainKHR.html
	CreateSwapchain(device core1_0.Device, allocation *driver.AllocationCallbacks, options SwapchainCreateInfo) (Swapchain, common.VkResult, error)
	// QueuePresent queues an Image for presentation
	// queue - A core1_0.Queue that is capable of presentation to the target khr_surface.Surface object's
	// platform on the same Device as the Image object's Swapchain
	//
	// o - Specifies parameters of the presentation
	//
	// https://registry.khronos.org/vulkan/specs/1.3-extensions/man/html/vkQueuePresentKHR.html
	QueuePresent(queue core1_0.Queue, o PresentInfo) (common.VkResult, error)
}

Extension contains all commands for the khr_swapchain extension (that were not added in core 1.1)

https://registry.khronos.org/vulkan/specs/1.3-extensions/man/html/VK_KHR_swapchain.html

type PresentInfo

type PresentInfo struct {
	// WaitSemaphores is a slice of Semaphore objects to wait for before issuing the present request
	WaitSemaphores []core1_0.Semaphore
	// Swapchains is a slice of Swapchain objects being presented to by this command
	Swapchains []Swapchain
	// ImageIndices is a slice of indices into the array of each Swapchain object's presentable Image objects.
	// Each entry in this slice identifies the Image to present on the corresponding entry in the Swapchains
	// slice.
	ImageIndices []int

	common.NextOptions

	// OutData is a struct whose contents will be populated by the present command. It may be left nil
	// if the caller is uninterested in this data.
	OutData *PresentOutData
}

PresentInfo describes parameters of a Queue presentation

https://registry.khronos.org/vulkan/specs/1.3-extensions/man/html/VkPresentInfoKHR.html

func (PresentInfo) PopulateCPointer

func (o PresentInfo) PopulateCPointer(allocator *cgoparam.Allocator, preallocatedPointer unsafe.Pointer, next unsafe.Pointer) (unsafe.Pointer, error)

func (PresentInfo) PopulateOutData

func (o PresentInfo) PopulateOutData(cDataPointer unsafe.Pointer) error

type PresentOutData

type PresentOutData struct {
	// Results is a slice of status codes, one for each Swapchain provided in PresentInfo.
	// This slice allows the caller to inspect the results of each individual Swapchain presentation
	// executed by Extension.QueuePresent
	Results []common.VkResult
}

PresentOutData represents optionally-returned data from the Extension.QueuePresent command

type Swapchain

type Swapchain interface {
	// Handle is the internal Vulkan object handle for this Swapchain
	Handle() khr_swapchain_driver.VkSwapchainKHR

	// Destroy deletes this Swapchain and underlying structures from the device. **Warning**
	// after destruction, this object will still exist, but the Vulkan object handle
	// that backs it will be invalid. Do not call further methods on this object.
	//
	// callbacks - A set of allocation callbacks to control the memory free behavior of this command
	//
	// https://registry.khronos.org/vulkan/specs/1.3-extensions/man/html/vkDestroySwapchainKHR.html
	Destroy(callbacks *driver.AllocationCallbacks)
	// SwapchainImages obtains a slice of the presentable Image objects associated with this Swapchain
	//
	// https://registry.khronos.org/vulkan/specs/1.3-extensions/man/html/vkGetSwapchainImagesKHR.html
	SwapchainImages() ([]core1_0.Image, common.VkResult, error)
	// AcquireNextImage retrieves the index of the next available presentable Image
	//
	// timeout - Specifies how long the function waits, in nanoseconds, if no Image is available, before
	// returning core1_0.VKTimeout. May be common.NoTimeout to wait indefinitely. The timeout is adjusted
	// to the closest value allowed by the implementation timeout accuracy, which may be substantially
	// longer than the requested timeout.
	//
	// semaphore - Optionally, a Semaphore to signal when the Image is acquired
	//
	// fence - Optionally, a Fence to signal when the Image is acquired
	//
	// https://registry.khronos.org/vulkan/specs/1.3-extensions/man/html/vkAcquireNextImageKHR.html
	AcquireNextImage(timeout time.Duration, semaphore core1_0.Semaphore, fence core1_0.Fence) (int, common.VkResult, error)
}

Swapchain provides the ability to present rendering results to a Surface

https://registry.khronos.org/vulkan/specs/1.3-extensions/man/html/VkSwapchainKHR.html

type SwapchainCreateFlags

type SwapchainCreateFlags int32

SwapchainCreateFlags controls swapchain creation

https://registry.khronos.org/vulkan/specs/1.3-extensions/man/html/VkSwapchainCreateFlagBitsKHR.html

func (SwapchainCreateFlags) Register

func (f SwapchainCreateFlags) Register(str string)

func (SwapchainCreateFlags) String

func (f SwapchainCreateFlags) String() string

type SwapchainCreateInfo

type SwapchainCreateInfo struct {
	// Surface is the khr_surface.Surface onto which the Swapchain will present Image objects
	Surface ext_surface.Surface

	// Flags - Indicates parameters of the Swapchain creation
	Flags SwapchainCreateFlags

	// MinImageCount is the minimum number of presentable Image objects that the application needs.
	// The implementation will either create the Swapchain with at least that many Image objects, or it
	// will fail to create the Swapchain
	MinImageCount int

	// ImageFormat specifies the format the Swapchain Image objects will be created with
	ImageFormat core1_0.Format
	// ImageColorSpace specifies the way the Swapchain interprets Image data
	ImageColorSpace ext_surface.ColorSpace
	// ImageExtent is the size, in pixels, of the Swapchain Image objects. The behavior is platform-dependent
	// if the Image extent does not match the Surface object's CurrentExtent as returned by
	// khr_surface.Surface.PhysicalDeviceSurfaceCapabilities
	ImageExtent core1_0.Extent2D
	// ImageArrayLayers is the number of views in a multiview/stereo Surface
	ImageArrayLayers int
	// ImageUsage describes the intended usage of the (acquired) Swapchain Image objects
	ImageUsage core1_0.ImageUsageFlags

	// ImageSharingMode is the sharing mode used for the Image objects of the Swapchain
	ImageSharingMode core1_0.SharingMode
	// QueueFamilyIndices is a slice of queue family indices having access to the Image objects of
	// the Swapchain when ImageSharingMode is SharingModeConcurrent
	QueueFamilyIndices []int

	// PreTransform describes the transform, relative to the presentation engine's natural orientation,
	// applied to the Image content prior to presentation
	PreTransform ext_surface.SurfaceTransformFlags
	// CompositeAlpha indicates the alpha compositing mode to use when this Surface is composited together
	// with other surfaces on certain window systems
	CompositeAlpha ext_surface.CompositeAlphaFlags
	// PresentMode is the presentation mode the Swapchain will use
	PresentMode ext_surface.PresentMode

	// Clipped specifies whether the Vulkan implementation is allowed to discard rendering operations that
	// affect regions of the Surface that are not visible
	Clipped bool
	// OldSwapchain is, optionally, the existing non-retired Swapchain currently associated with Surface.
	// Providing a valid OldSwapchain may aid in resource reuse, and also allows the application to still
	// present any Image objects that are already acquired from it
	OldSwapchain Swapchain

	common.NextOptions
}

SwapchainCreateInfo specifies parameters of a newly-created Swapchain object

https://registry.khronos.org/vulkan/specs/1.3-extensions/man/html/VkSwapchainCreateInfoKHR.html

func (SwapchainCreateInfo) PopulateCPointer

func (o SwapchainCreateInfo) PopulateCPointer(allocator *cgoparam.Allocator, preallocatedPointer unsafe.Pointer, next unsafe.Pointer) (unsafe.Pointer, error)

type VulkanExtension

type VulkanExtension struct {
	// contains filtered or unexported fields
}

VulkanExtension is an implementation of the Extension interface that actually communicates with Vulkan. This is the default implementation. See the interface for more documentation.

func CreateExtensionFromDevice

func CreateExtensionFromDevice(device core1_0.Device) *VulkanExtension

CreateExtensionFromDevice produces an Extension object from a Device with khr_swapchain loaded

func CreateExtensionFromDriver

func CreateExtensionFromDriver(driver khr_swapchain_driver.Driver) *VulkanExtension

CreateExtensionFromDriver generates an Extension from a driver.Driver object- this is usually used in tests to build an Extension from mock drivers

func (*VulkanExtension) APIVersion

func (e *VulkanExtension) APIVersion() common.APIVersion

func (*VulkanExtension) CreateSwapchain

func (e *VulkanExtension) CreateSwapchain(device core1_0.Device, allocation *driver.AllocationCallbacks, options SwapchainCreateInfo) (Swapchain, common.VkResult, error)

func (*VulkanExtension) Driver

func (*VulkanExtension) QueuePresent

func (e *VulkanExtension) QueuePresent(queue core1_0.Queue, o PresentInfo) (common.VkResult, error)

type VulkanSwapchain

type VulkanSwapchain struct {
	// contains filtered or unexported fields
}

VulkanSwapchain is an implementation of the Swapchain interface that actually communicates with Vulkan. This is the default implementation. See the interface for more documentation.

func (*VulkanSwapchain) AcquireNextImage

func (s *VulkanSwapchain) AcquireNextImage(timeout time.Duration, semaphore core1_0.Semaphore, fence core1_0.Fence) (int, common.VkResult, error)

func (*VulkanSwapchain) Destroy

func (s *VulkanSwapchain) Destroy(callbacks *driver.AllocationCallbacks)

func (*VulkanSwapchain) Handle

func (*VulkanSwapchain) SwapchainImages

func (s *VulkanSwapchain) SwapchainImages() ([]core1_0.Image, common.VkResult, error)

Directories

Path Synopsis
Package mock_swapchain is a generated GoMock package.
Package mock_swapchain is a generated GoMock package.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL