ffi

package
v0.3.21 Latest Latest
Warning

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

Go to latest
Published: Nov 12, 2026 License: MIT, MIT Imports: 5 Imported by: 0 modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Overview

Package ffi is the slice of goffi's API the Vulkan bindings call through, carried out by github.com/ebitengine/purego: purego and goffi each link a runtime shim (fakecgo) and cannot share a program, and purego is the one lys-ui's applications already use to load native libraries.

Every Vulkan argument and result is an integer, a handle or a pointer, passed in integer registers. Float arguments (only a few rarely used commands, such as vkCmdSetLineWidth, take any) would travel in float registers, which purego.SyscallN does not fill, so a call with one panics rather than pass garbage.

Index

Constants

This section is empty.

Variables

View Source
var (
	VoidTypeDescriptor    = &TypeDescriptor{Kind: VoidType}
	UInt32TypeDescriptor  = &TypeDescriptor{Kind: UInt32Type}
	SInt32TypeDescriptor  = &TypeDescriptor{Kind: SInt32Type}
	UInt64TypeDescriptor  = &TypeDescriptor{Kind: UInt64Type}
	PointerTypeDescriptor = &TypeDescriptor{Kind: PointerType}
	FloatTypeDescriptor   = &TypeDescriptor{Kind: FloatType}
)

The C types the bindings use.

Functions

func CallFunction

func CallFunction(cif *CallInterface, fn unsafe.Pointer, rvalue unsafe.Pointer, avalue []unsafe.Pointer) (uintptr, error)

CallFunction calls fn with the arguments avalue points at, each read as its prepared type, and stores the result where rvalue points (nil for a void function). The errno result is always zero. The C side gets the arguments as integers, which keep nothing alive, so avalue, and through it every structure an argument points at, stays reachable until the call returns: otherwise a collection during a long call (vkCreateInstance) frees what the driver is reading, and another goroutine's allocation overwrites it.

func FreeLibrary

func FreeLibrary(handle unsafe.Pointer) error

FreeLibrary closes a library LoadLibrary opened.

func GetSymbol

func GetSymbol(handle unsafe.Pointer, name string) (unsafe.Pointer, error)

GetSymbol looks name up in the library handle opened.

func LoadLibrary

func LoadLibrary(name string) (unsafe.Pointer, error)

LoadLibrary opens the shared library name.

func PrepareCallInterface

func PrepareCallInterface(cif *CallInterface, _ CallingConvention, ret *TypeDescriptor, args []*TypeDescriptor) error

PrepareCallInterface records a function's result and argument types.

Types

type CallInterface

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

CallInterface is a prepared signature.

type CallingConvention

type CallingConvention int

CallingConvention is goffi's; only the platform default exists here.

const DefaultCall CallingConvention = 0

DefaultCall is the platform's C calling convention.

type TypeDescriptor

type TypeDescriptor struct{ Kind TypeKind }

TypeDescriptor describes a C type.

type TypeKind

type TypeKind int

TypeKind is a C type's category.

const (
	VoidType TypeKind = iota
	UInt32Type
	SInt32Type
	UInt64Type
	PointerType
	FloatType
)

The kinds an argument or result can have.

Jump to

Keyboard shortcuts

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