Documentation
¶
Overview ¶
Package vkgen reads the Khronos registry (vk.xml) and generates the Go mirrors of the Vulkan structures, enumerations and handles that go-gfx/vulkan calls. Offsets and sizes are computed by the C rules for a 64-bit target, and the generator emits a test that pins every Go struct against that table, so that a layout has a witness other than the hand that typed it.
Index ¶
Constants ¶
const MaxRegistryBytes = 64 << 20
MaxRegistryBytes bounds the registry the reader accepts: the real file is about 3.3 MB, and the reader is fuzzed with arbitrary bytes.
Variables ¶
This section is empty.
Functions ¶
func OpenRegistry ¶
func OpenRegistry(path string) (io.ReadCloser, error)
OpenRegistry opens a registry file; a name ending in .gz is decompressed. The repository keeps vk.xml.gz (3.3 MB of XML is 0.3 MB gzipped), and Parse bounds the decompressed size, so a gzip bomb is refused.
Types ¶
type Config ¶
type Config struct {
Package string
Structs []string // structures to mirror, and every type they reach
Handles []string // handles to declare even when no structure holds them
Enums []string // enumerations whose every enumerator becomes a constant
Constants []string // API constants (VK_WHOLE_SIZE)
}
Config says what to generate. Names are the registry's (VkBufferCreateInfo).
func DefaultConfig ¶
func DefaultConfig() Config
DefaultConfig is what go-gfx/vulkan calls: exactly the structures, handles and enumerations of the compute path, and nothing for presentation.
type Member ¶
type Member struct {
Name string
Type string
Pointer bool // a pointer of any depth: the generator mirrors it as unsafe.Pointer
Dims []string // array dimensions, each a number or the name of a constant
Bits string // bit-field width, unsupported by the generator
Values string // the fixed value of an sType member
}
Member is one field of a structure, as the registry spells it.
type Registry ¶
type Registry struct {
Structs map[string]*Struct
Enums map[string]*Enum
EnumTypes map[string]bool // names declared with category="enum"
Constants map[string]Constant
Base map[string]string // VkFlags -> uint32_t
Flags map[string]string // VkBufferCreateFlags -> VkFlags
Handles map[string]bool // name -> dispatchable
Aliases map[string]string // alias -> target, for structs, enums, handles
Version string // VK_HEADER_VERSION, when found
// contains filtered or unexported fields
}
Registry is what the generator needs of vk.xml.