vks is a Vulkan bridge for Go.

Related tags

Network vks
Overview

vks

vks is a Vulkan bridge for Go. The header generator folder contains the code that is used to generate the vulkan bindings. It woks similar to c-for-go, but it uses the vulkan specification published as XML to generate the output bindings.

Memory management

Unlike c-for-go, this wrapper does very little memory management for you. Most of the logic is for converting from Cgo types into go types, but ensuring that C memory is allocated and released is up to the program, not to this binding.

Completeness

Currently, the header is only generating implementatations for the features in the "vulkan" API for 1.0, 1.1, and 1.2.

Nothing is done to "fix" the names of functions or types. That means typing "vks.Vk" frequently. There are a couple of functions where I've taken a first stab at providing a more go-friendly wrapper ontop of the function, but for the most part, everything is working directly with the vulkan API.

it also currently depends on the vulkan prototypes and linking with the vulkan library when building.

Example application

package main

import (
	"log"
	"unsafe"

	"github.com/ibd1279/vks"
)

func main() {
	if layProps, result := vks.EnumerateInstanceLayerProperties(); result.IsSuccess() {
		for k, v := range layProps {
			name := vks.ToString(v.LayerName())
			log.Printf("layer %d %v %d %t", k, name, len(name), "VK_LAYER_LUNARG_api_dump" == name)
		}
	}
	if extProps, result := vks.EnumerateInstanceExtensionProperties(""); result.IsSuccess() {
		for k, v := range extProps {
			name := vks.ToString(v.ExtensionName())
			log.Printf("extension %d %v %d %t", k, name, len(name), "VK_KHR_surface" == name)
		}
	}
	if version, result := vks.EnumerateInstanceVersion(); result.IsSuccess() {
		log.Printf("%v", version)
	}

	appInfo := new(vks.VkApplicationInfo).
		WithDefaultSType().
		WithApplication("Test", vks.MakeApiVersion(0, 1, 0, 0)).
		WithEngine("NoEngine", vks.MakeApiVersion(0, 1, 0, 0)).
		WithApiVersion(uint32(vks.VK_API_VERSION_1_2)).
		AsCPtr()
	createInfo := new(vks.VkInstanceCreateInfo).
		WithDefaultSType().
		WithPApplicationInfo(appInfo).
		WithLayers([]string{"VK_LAYER_KHRONOS_validation"}).
		WithExtensions([]string{"VK_KHR_surface"}).
		AsCPtr()
	defer func() { createInfo.Free(); appInfo.Free() }()

	var instance vks.VkInstance
	if err := vks.VkCreateInstance(createInfo, nil, &instance).AsErr(); err != nil {
		panic(err)
	}

	if phyDevs, result := vks.EnumeratePhysicalDevices(instance); result.IsSuccess() {
		for k, phyDev := range phyDevs {
			driverProps := new(vks.VkPhysicalDeviceDriverProperties).
				WithDefaultSType().
				AsCPtr()
			defer func() { driverProps.Free() }()

			props := new(vks.VkPhysicalDeviceProperties2).
				WithDefaultSType().
				WithPNext(unsafe.Pointer(driverProps)).
				AsPtr()

			vks.VkGetPhysicalDeviceProperties2(phyDev, props)

			name := vks.ToString(props.Properties().DeviceName())
			apiVersion := vks.Version(props.Properties().ApiVersion())
			devType := props.Properties().DeviceType()
			driverVersion := vks.Version(props.Properties().DriverVersion())
			vendorId := props.Properties().VendorID()
			driverInfo := vks.ToString(driverProps.DriverInfo())
			driverName := vks.ToString(driverProps.DriverName())

			log.Printf("physical device %d %s %s - %s - %d %s %s %s", k, name, devType,
				apiVersion,
				vendorId, driverName, driverVersion, driverInfo)
		}
	}

	vks.VkDestroyInstance(instance, nil)
}
Comments
  • Vulkan 1.3 Example doesn't work on macOS

    Vulkan 1.3 Example doesn't work on macOS

    The provided example code will build but will not run with Vulkan 1.3.

    Beginning with the 1.3.216 Vulkan SDK, the Vulkan Loader is strictly enforcing the new VK_KHR_PORTABILITY_subset extension. The current example does not do this and won't run on a mac using MoltenVK.

    opened by ibd1279 1
  • The union types in the vulkan spec aren't supported.

    The union types in the vulkan spec aren't supported.

    The union types in the vulkan specification (e.g. VkClearColorValue) are not supported.

    Expected -- the ability to use these union types. Actual -- they are supported.

    Details The identifier for the unions exist, they get output as a renamed typed (e.g. type ClearColorValue C.VkClearColorValue), but the ability to access any of the underlying types does not exist. This is partly because Cgo does not export union members. Instead it treats the union type as an array of bytes that can hold the largest member. (See this old golang-nuts thread ).

    To experiment, I added some helpers to unblock the tutorial code, but the reality is that the header-generator stuff needs to provide some level of support for the union types by either generating these helpers or by creating a different abstraction.

    opened by ibd1279 0
  • Surface From Pointer missing.

    Surface From Pointer missing.

    Vulkan-go had a SurfaceFromPointer function. While the function itself doesn't do much, it does hide away the unsafe package. Not sure if something similar should be added to vks.

    opened by ibd1279 0
  • Doesn't compile

    Doesn't compile

    When I try compiling the example, I get the following error:

    # github.com/ibd1279/vks
    ../vk_wrapper.go:14751:84: x.headerSize undefined (type PipelineCacheHeaderVersionOne has no field or method headerSize, but does have HeaderSize)
    ../vk_wrapper.go:14758:4: x.headerSize undefined (type PipelineCacheHeaderVersionOne has no field or method headerSize, but does have HeaderSize)
    ../vk_wrapper.go:14764:56: x.headerVersion undefined (type PipelineCacheHeaderVersionOne has no field or method headerVersion, but does have HeaderVersion)
    ../vk_wrapper.go:14771:4: x.headerVersion undefined (type PipelineCacheHeaderVersionOne has no field or method headerVersion, but does have HeaderVersion)
    ../vk_wrapper.go:14777:84: x.vendorID undefined (type PipelineCacheHeaderVersionOne has no field or method vendorID, but does have VendorID)
    ../vk_wrapper.go:14784:4: x.vendorID undefined (type PipelineCacheHeaderVersionOne has no field or method vendorID, but does have VendorID)
    ../vk_wrapper.go:14790:84: x.deviceID undefined (type PipelineCacheHeaderVersionOne has no field or method deviceID, but does have DeviceID)
    ../vk_wrapper.go:14797:4: x.deviceID undefined (type PipelineCacheHeaderVersionOne has no field or method deviceID, but does have DeviceID)
    ../vk_wrapper.go:14806:7: x.pipelineCacheUUID undefined (type PipelineCacheHeaderVersionOne has no field or method pipelineCacheUUID, but does have PipelineCacheUUID)
    ../vk_wrapper.go:14821:9: x.pipelineCacheUUID undefined (type PipelineCacheHeaderVersionOne has no field or method pipelineCacheUUID, but does have PipelineCacheUUID)
    ../vk_wrapper.go:14821:9: too many errors
    
    opened by Nv7-GitHub 17
  • Suggestion: Add glfw example

    Suggestion: Add glfw example

    Hi Jason!

    I think it would be really helpful if you would throw in an example of "how to use with glfw - draw triangle".

    If you need help writing up some examples i can help you out.

    At a first look your library seems very promising and i am really looking forward to giving it a Go! ;)

    opened by jensfredgaard 6
Owner
Jason Watson
Jason Watson
A Matrix-iMessage puppeting bridge

A Matrix-iMessage puppeting bridge. The bridge runs on a Mac or jailbroken iPhone (soon™). A websocket proxy is required to receive appservice events from the homeserver.

Tulir Asokan 151 Jan 2, 2023
Bridge between mattermost, IRC, gitter, xmpp, slack, discord, telegram, rocketchat, twitch, ssh-chat, zulip, whatsapp, keybase, matrix, microsoft teams, nextcloud, mumble, vk and more with REST API

bridge between mattermost, IRC, gitter, xmpp, slack, discord, telegram, rocketchat, twitch, ssh-chat, zulip, whatsapp, keybase, matrix, microsoft teams, nextcloud, mumble, vk and more with REST API (mattermost not required!)

Wim 5.4k Jan 4, 2023
An inline buildpack for deploying a mattermost-irc bridge

Matterbridge-Heroku An inline buildpack for hosting Matterbridge on Heroku. Heroku is a platform for easily deploying applications. A buildpack provid

Christopher DeCairos 11 Nov 26, 2022
Bridge facebook messenger with any service supported by matterbridge

fbridge fbridge bridges facebook messenger with any service supported by matterbridge trough the API interface. fbridge is using fbchat to connect to

null 28 Oct 30, 2022
Facebook bridge used with matterbridge

fbridge-asyncio This repo is a fork of fbridge. If you log in to your facebook account from a browser, after you do, it's a good idea to restart fbrid

null 8 Aug 7, 2022
Grpc bridge to various mediabank related systems

Mediabank bridge This internal tool enables authenticated gRPC based endpoint for securely communicating with systems like: Telestream Vantage Workflo

BCC Code 0 Jan 7, 2022
Bridge REMOV will allow you to safely transfer NFT from RMRK to MOVR and backwards

remov Inspiration Our aim is to expand the capabilities of blockchain and make a secure way for transferring NFT between RMRK and MOVR blockchain. The

null 1 Dec 5, 2021
Celestia -> EVM bridge

Peggo Peggo is a Go implementation of the Peggy (Gravity Bridge) Orchestrator originally implemented by Injective Labs. Peggo itself is a fork of the

Celestia 64 Dec 12, 2022
A REST API for the DN42 registry, written in Go, to provide a bridge between interactive applications and the registry.

dn42regsrv A REST API for the DN42 registry, written in Go, to provide a bridge between interactive applications and registry data. A public instance

Simon Marsh 0 Apr 21, 2022
The official repository of the Gravity Bridge Blockchain

Gravity bridge is Cosmos <-> Ethereum bridge designed to run on the Cosmos SDK blockchains like the Cosmos Hub focused on maximum design simplicity an

Gravity Bridge Foundation 117 Dec 27, 2022
A bridge from the Stellar network to other blockchains

Creating equitable access to the global financial system Starbridge Starbridge is software that facilitates bridge builders who are connecting the Ste

Stellar 38 Dec 9, 2022
RuuviBridge - Utility to bridge RuuviTag data between various sources and consumers

RuuviBridge RuuviBridge is designed to act as a "data bridge" between various so

Scrin 14 Nov 19, 2022
🧙 High-performance PHP-to-Golang IPC/RPC bridge

High-performance PHP-to-Golang IPC bridge Goridge is high performance PHP-to-Golang codec library which works over native PHP sockets and Golang net/r

RoadRunner 1.1k Dec 28, 2022
Apex-api-bridge - Bridge between apexlegendsapi and ApeStats

apex-api-sync This app updates a mongo instance with the players most recent dat

null 1 Feb 17, 2022
Vulkan API bindings for Go programming language

Golang Bindings for Vulkan API Package vulkan provides Go bindings for Vulkan — a low-overhead, cross-platform 3D graphics and compute API. Updated Oc

null 665 Jan 3, 2023
An experimental vulkan 3d engine for linux (raspberry 4)

protomatter an experimental vulkan 3d engine for linux (raspberry 4).

Torben Schinke 0 Nov 14, 2021
A Matrix-iMessage puppeting bridge

A Matrix-iMessage puppeting bridge. The bridge runs on a Mac or jailbroken iPhone (soon™). A websocket proxy is required to receive appservice events from the homeserver.

Tulir Asokan 151 Jan 2, 2023
High-performance PHP-to-Golang IPC bridge

High-performance PHP-to-Golang IPC bridge Goridge is high performance PHP-to-Golang codec library which works over native PHP sockets and Golang net/r

Spiral Scout 1.1k Dec 28, 2022
Generic Prometheus ⟷ MQTT Bridge

Promqtt: Prometheus ⟷ MQTT Bridge Promqtt makes Prometheus MQTT capable in a truly generic way. It has no assumptions on message payloads or topic lay

sh0rez 16 Sep 18, 2022
Zero-knowledge-proof verification bridge

Submit Bug Rosefintech-Rosl2-Bridge Zero knowledge proof verification bridge Table of Contents Security Background Install Community Contact License S

Rosefintech 16 Jun 4, 2022