common

package
v2.2.1 Latest Latest
Warning

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

Go to latest
Published: Apr 26, 2023 License: MIT Imports: 9 Imported by: 127

Documentation

Index

Examples

Constants

View Source
const (
	MaxMemoryTypes int = C.VK_MAX_MEMORY_TYPES
	MaxMemoryHeaps int = C.VK_MAX_MEMORY_HEAPS
	WholeSize      int = -1
)
View Source
const NoTimeout = time.Duration(^int64(0))

NoTimeout can be passed to any Vulkan command or field which accepts a timeout in order to indicate that the method should take as long as necessary.

Variables

View Source
var ByteOrder = binary.LittleEndian

ByteOrder provides binary.LittleEndian or binary.BigEndian, depending on the current platform

Functions

func AllocOptionSlice

func AllocOptionSlice[T any, O Options](allocator *cgoparam.Allocator, o []O) (*T, error)

AllocOptionSlice is used to receive a C-allocated array for several chains of Options structs. If you are not contributing to vkngwrapper or writing a Vulkan extension wrapper, you do not need to understand this method.

func AllocOptions

func AllocOptions(allocator *cgoparam.Allocator, o Options, preallocatedPointer ...unsafe.Pointer) (unsafe.Pointer, error)

AllocOptions is used to receive a C-allocated pointer for a chain of Options structs. If you are not contributing to vkngwrapper or writing a Vulkan extension wrapper, you do not need to understand this method.

func AllocOutDataHeader

func AllocOutDataHeader(allocator *cgoparam.Allocator, o OutData, preallocatedPointer ...unsafe.Pointer) (unsafe.Pointer, error)

AllocOutDataHeader is used to receive a C-allocated pointer for a chain of OutData structs. If you are not contributing to vkngwrapper or writing a Vulkan extension wrapper, you do not need to understand this method.

func AllocOutDataHeaderSlice

func AllocOutDataHeaderSlice[T any, O OutData](allocator *cgoparam.Allocator, o []O) (*T, error)

AllocOutDataHeaderSlice is used to receive a C-allocated array for several chains of OutData structs. If you are not contributing to vkngwrapper or writing a Vulkan extension wrapper, you do not need to understand this method.

func AllocSlice

func AllocSlice[T any, A CAllocatable](allocator *cgoparam.Allocator, a []A) (*T, error)

AllocSlice is used to receive a C-allocated array for several CAllocator objects. If you are not contributing to vkngwrapper or writing a Vulkan extension wrapper, you do not need to understand this method.

func OfType

func OfType[T any](values []any) (T, bool)

OfType locates the first value in an untyped array which matches the parameter type and returns it, if any. Otherwise, it will return the default value of the parameter type. an `ok` return value is included, for convenience. If you are not contributing to vkngwrapper or writing a Vulkan extension wrapper, you do not need to understand this method.

func PopulateOutData

func PopulateOutData(o OutData, cPointer unsafe.Pointer, helpers ...any) error

PopulateOutData populates fields in a chain of OutData objects from the same chain in a C pointer. The C pointer should have been previously allocated with AllocOutDataHeader and populated with a call to a Vulkan command. If you are not contributing to vkngwrapper or writing a Vulkan extension wrapper, you do not need to understand this method.

func PopulateOutDataSlice

func PopulateOutDataSlice[T any, O OutData](o []O, cSlicePointer unsafe.Pointer, helpers ...any) error

PopulateOutDataSlice populates fields in a slice of OutData chains from an array of chains in a C pointer. The C pointer should have been previously allocated with AllocOutDataHeaderSlice and populated with a call to a Vulkan command. If you are not contributing to vkngwrapper or writing a Vulkan extension wrapper, you do not need to understand this method.

func TimeoutNanoseconds

func TimeoutNanoseconds(timeout time.Duration) uint64

TimeoutNanoseconds converts a time.Duration into a timeout value acceptable to any Vulkan command or field which accepts a timeout.

Types

type APIVersion

type APIVersion uint32

APIVersion is an API version number, represents a single release of the Vulkan API

const (
	// Vulkan1_0 indicates core 1.0
	Vulkan1_0 APIVersion = C.VK_API_VERSION_1_0
	// Vulkan1_1 indicates core 1.1
	Vulkan1_1 APIVersion = C.VK_API_VERSION_1_1
	// Vulkan1_2 indicates core 1.2
	Vulkan1_2 APIVersion = C.VK_API_VERSION_1_2
)

func (APIVersion) IsAtLeast

func (v APIVersion) IsAtLeast(otherVersion APIVersion) bool

IsAtLeast returns true if the receiver v represents an API version greater than or equal to the argument otherVersion, or false otherwise.

func (APIVersion) Major

func (v APIVersion) Major() uint32

Major is the major version number of the APIVersion number- this is the first number in the vulkan version number. In API version 1.2.189, the major version is 1.

func (APIVersion) MatchesMajorVersion

func (v APIVersion) MatchesMajorVersion(otherVersion APIVersion) bool

MatchesMajorVersion will return true if the receiver v and the argument otherVersion have the same Variant and Major versions, or false otherwise.

func (APIVersion) MatchesMinorVersion

func (v APIVersion) MatchesMinorVersion(otherVersion APIVersion) bool

MatchesMinorVersion will return true if the receiver v and the argument otherVersion have the same Variant, Major, and Minor versions, or false otherwise.

func (APIVersion) Max

func (v APIVersion) Max(otherVersion APIVersion) APIVersion

Max returns the greater of the two APIVersions: the receiver v, or the argument otherVersion.

func (APIVersion) Min

func (v APIVersion) Min(otherVersion APIVersion) APIVersion

Min returns the lower of the two APIVersions: the receiver v, or the argument otherVersion.

func (APIVersion) Minor

func (v APIVersion) Minor() uint32

Minor is the minor version number of the APIVersion number- this is the second number in the vulkan version number. In API version 1.2.189, the minor version is 2.

func (APIVersion) Patch

func (v APIVersion) Patch() uint32

Patch is the patch version number of the APIVersion number- this is the third number in the vulkan version number. In API version 1.2.189, the patch version is 189.

func (APIVersion) String

func (v APIVersion) String() string

String provides an attractively-formatted Vulkan api version

func (APIVersion) Variant

func (v APIVersion) Variant() uint32

Variant is the variant number of the APIVersion number- this number is rarely included in vulkan version numbering, and vkngwrapper only supports variant 0. In API version 1.2.189, the variant is 0.

type AllocationCallbackOptions

type AllocationCallbackOptions struct {
	// An arbitrary go object that will be passed to all registered callbacks
	UserData any
	// Callback, executed to allocate host memory
	Allocation AllocationFunction
	// Callback, executed to reallocate host memory
	Reallocation ReallocationFunction
	// Callback, executed to free host memory
	Free FreeFunction
	// Callback, executed on all internal memory allocations
	InternalAllocation InternalAllocationNotification
	// Callback, executed on all internal memory frees
	InternalFree InternalFreeNotification
}

AllocationCallbackOptions defines a set of callbacks and a piece of userdata that can be baked into a driver.AllocationCallbacks with driver.CreateAllocationCallbacks. driver.AllocationCallbacks objects are immutable, so it may be valuable to hold onto your AllocationCallbackOptions object in order to allow changes over time, if that is necessary.

All fields in this struct are optional: any nil callback will not be executed by Vulkan, and nil UserData will be passed as-is to any executed callback.

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

type AllocationFunction

type AllocationFunction func(userData any, size int, alignment int, allocationScope SystemAllocationScope) unsafe.Pointer

AllocationFunction is an application-defined memory allocation function. It can be registered with Vulkan via driver.CreateAllocationCallbacks in order to allow users to override the default Vulkan host memory allocation behavior. Beware: this should provide unsafe.Pointers to **C** memory, not go memory!

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

type CAllocatable

type CAllocatable interface {
	PopulateCPointer(allocator *cgoparam.Allocator, preallocatedPointer unsafe.Pointer) (unsafe.Pointer, error)
}

CAllocatable is implemented by vkngwrapper structures that are not chainable (do not have Next* fields) but need to be allocatable with AllocSlice or PopulateCPointer. If you are not contributing to vkngwrapper or writing a Vulkan extension wrapper, you do not need to understand this type.

type FlagStringMapping

type FlagStringMapping[T flags] struct {
	// contains filtered or unexported fields
}

FlagStringMapping is used as a base type for many bitflag enums in vkngwrapper. It has the capability to Register flags with a descriptive string in an init() method. Once that has done, the flag type can be stringified into a pipe-separated list of flags.

Example
package main

import (
	"fmt"
	"github.com/vkngwrapper/core/v2/common"
)

type CoolFlags int32

var coolFlagsMapping = common.NewFlagStringMapping[CoolFlags]()

func (f CoolFlags) Register(str string) {
	coolFlagsMapping.Register(f, str)
}

func (f CoolFlags) String() string {
	return coolFlagsMapping.FlagsToString(f)
}

const (
	CoolFlagsRed  CoolFlags = 1
	CoolFlagsBlue CoolFlags = 2
)

func init() {
	CoolFlagsRed.Register("Red")
	CoolFlagsBlue.Register("Blue")
}

func main() {
	fmt.Println(CoolFlagsBlue | CoolFlagsRed)
}
Output:

Red|Blue

func NewFlagStringMapping

func NewFlagStringMapping[T flags]() FlagStringMapping[T]

NewFlagStringMapping creates a FlagStringMapping for use in flag types

func (FlagStringMapping[T]) FlagsToString

func (m FlagStringMapping[T]) FlagsToString(value T) string

FlagsToString returns a formatted string representing the flag value passed in. It is a pipe-separated list of descriptive strings for each flag active in the value.

func (FlagStringMapping[T]) Register

func (m FlagStringMapping[T]) Register(value T, str string)

Register maps a flag value to a string that will represent that flag when using String(). It is best to call this from init()

type FreeFunction

type FreeFunction func(userData any, memory unsafe.Pointer)

FreeFunction is an application-defined memory free function. It can be registered with Vulkan via driver.CreateAllocationCallbacks in order to allow users to override the default Vulkan host memory free behavior.

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

type InternalAllocationNotification

type InternalAllocationNotification func(userData any, size int, allocationType InternalAllocationType, allocationScope SystemAllocationScope)

InternalAllocationNotification is an application-defined function to received allocation notifications. It is purely an informational callback. It can be registered with Vulkan via driver.CreateAllocationCallbacks in order to allow users to receive notifications when the Vulkan host makes memory allocations.

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

type InternalAllocationType

type InternalAllocationType int32

InternalAllocationType classifies in an internal allocation in an AllocationCallbackOptions notification callback.

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

const (

	// InternalAllocationTypeExecutable specifies that the allocation is intended for execution by the host.
	InternalAllocationTypeExecutable InternalAllocationType = C.VK_INTERNAL_ALLOCATION_TYPE_EXECUTABLE
)

func (InternalAllocationType) Register

func (e InternalAllocationType) Register(str string)

func (InternalAllocationType) String

func (e InternalAllocationType) String() string

type InternalFreeNotification

type InternalFreeNotification func(userData any, size int, allocationType InternalAllocationType, allocationScope SystemAllocationScope)

InternalFreeNotification is an application-defined function to receive free notifications. It is purely an informational callback. It can be registered with Vulkan via driver.CreateAllocationCallbacks in order to allow users to receive notifications when the Vulkan host frees memory.

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

type NextOptions

type NextOptions struct {
	Next Options
}

NextOptions is embedded by all vkngwrapper structures that pass input into Vulkan and are chainable. If you are wondering which structures can chain onto which other structures, all structures which embed NextOptions can be chained onto any other structures which embeds NextOptions, without exploding. However, you will need to refer to the Vulkan spec to see which chains actually do something worthwhile, and the validation layer may take issue with chains that do not match the spec.

func (NextOptions) NextOptionsInChain

func (n NextOptions) NextOptionsInChain() Options

type NextOutData

type NextOutData struct {
	Next OutData
}

NextOutData is embedded by all vkngwrapper structures that receive output from Vulkan and are chainable. If you are wondering which structures can chain onto which other structures, all structures which embed NextOutData can be chained onto any other structures which embeds NextOutData, without exploding. However, you will need to refer to the Vulkan spec to see which chains actually do something worthwhile, and the validation layer may take issue with chains that do not match the spec.

func (NextOutData) NextOutDataInChain

func (n NextOutData) NextOutDataInChain() OutData

type Options

type Options interface {
	PopulateCPointer(allocator *cgoparam.Allocator, preallocatedPointer unsafe.Pointer, next unsafe.Pointer) (unsafe.Pointer, error)

	NextOptionsInChain() Options
}

Options is implemented by vkngwrapper structures that pass input into Vulkan and are chainable via NextOptions. If you are not contributing to vkngwrapper or writing a Vulkan extension wrapper, you do not need to understand this type.

type OutData

type OutData interface {
	PopulateHeader(allocator *cgoparam.Allocator, preallocatedPointer unsafe.Pointer, next unsafe.Pointer) (unsafe.Pointer, error)
	PopulateOutData(cDataPointer unsafe.Pointer, helpers ...any) (next unsafe.Pointer, err error)

	NextOutDataInChain() OutData
}

OutData is implemented by vkngwrapper structures that receive output from Vulkan and are chainable via NextOutData. If you are not contributing to vkngwrapper or writing a Vulkan extension wrapper, you do not need to understand this type.

type ReallocationFunction

type ReallocationFunction func(userData any, original unsafe.Pointer, size int, alignment int, allocationScope SystemAllocationScope) unsafe.Pointer

ReallocationFunction is an application-defined memory reallocation function. It can be registered with Vulkan via driver.CreateAllocationCallbacks in order to allow users to override the default Vulkan host memory reallocation behavior. `original` is a pointer to the memory being reallocated, and may be nil. When `original` is nil, ReallocationFunction must act equivalently to the AllocationFunction in the same AllocationCallbacks object. Beware: this should provide unsafe.Pointers to **C** memory, not Go memory!

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

type SystemAllocationScope

type SystemAllocationScope int32

SystemAllocationScope indicates how long an allocation is intended to last in an AllocationCallbacksOptions allocation callback

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

const (

	// SystemAllocationScopeCommand specifies that the allocation is scoped to the duration of the Vulkan command
	SystemAllocationScopeCommand SystemAllocationScope = C.VK_SYSTEM_ALLOCATION_SCOPE_COMMAND
	// SystemAllocationScopeObject specifies that the allocation is scoped to the lifetime of the Vulkan object that is being created or used.
	SystemAllocationScopeObject SystemAllocationScope = C.VK_SYSTEM_ALLOCATION_SCOPE_OBJECT
	// SystemAllocationScopeCache specifies that the allocation is scoped to the lifetime of a VkPipelineCache or VkValidationCacheEXT object.
	SystemAllocationScopeCache SystemAllocationScope = C.VK_SYSTEM_ALLOCATION_SCOPE_CACHE
	// SystemAllocationScopeDevice specifies that the allocation is scoped to the lifetime of the Vulkan device.
	SystemAllocationScopeDevice SystemAllocationScope = C.VK_SYSTEM_ALLOCATION_SCOPE_DEVICE
	// SystemAllocationScopeInstance specifies that the allocation is scoped to the lifetime of the Vulkan instance.
	SystemAllocationScopeInstance SystemAllocationScope = C.VK_SYSTEM_ALLOCATION_SCOPE_INSTANCE
)

func (SystemAllocationScope) Register

func (e SystemAllocationScope) Register(str string)

func (SystemAllocationScope) String

func (e SystemAllocationScope) String() string

type Version

type Version uint32

Version is an integer intended to represent a semantic version, with major, minor and patch versions, like 1.2.5

func CreateVersion

func CreateVersion(major, minor, patch uint32) Version

CreateVersion generates a Version value for the given semantic version

func (Version) Major

func (v Version) Major() uint32

Major retrieves the major version value for a Version. In version 1.2.5, 1 is the major version.

func (Version) Minor

func (v Version) Minor() uint32

Minor retrieves the minor version value for a Version. In version 1.2.5, 2 is the minor version.

func (Version) Patch

func (v Version) Patch() uint32

Patch retrieves the patch version value for a Version. In version 1.2.5, 5 is the patch version.

func (Version) String

func (v Version) String() string

String generates an aesthetically-pleasing semantic version tag for a Version.

type VkResult

type VkResult int

VkResult is a return code used by many Vulkan commands to indicate failure cases or other status information.

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

func (VkResult) Register

func (e VkResult) Register(str string)

func (VkResult) String

func (e VkResult) String() string

func (VkResult) ToError

func (e VkResult) ToError() error

type VkResultError

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

VkResultError is an error object wrapping a VkResult return code. Any Vulkan command which returns a VkResult will return a VkResultError when returning a VkResult that indicates an error. Be aware: there are many non-VK_SUCCESS, non-error return codes!

func (*VkResultError) Error

func (err *VkResultError) Error() string

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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