Vulkan API bindings for Go programming language

Golang Bindings for Vulkan API version-1.1.88 GoDoc

Package vulkan provides Go bindings for Vulkan — a low-overhead, cross-platform 3D graphics and compute API. Updated October 13, 2018 — Vulkan 1.1.88.

Introduction

Vulkan API is the result of 18 months in an intense collaboration between leading hardware, game engine and platform vendors, built on significant contributions from multiple Khronos members. Vulkan is designed for portability across multiple platforms with desktop and mobile GPU architectures.

Read the brief: https://developer.nvidia.com/engaging-voyage-vulkan

The binding allows one to use Vulkan API directly within Go code, avoiding adding lots of C/C++ in the projects, also can be used to study Vulkan without diving too deep into C/C++ language semantics. For me it's just a matter of taste, writing Go code is simply more pleasant experience.

Project history timeline

  • 2016-02-16 Vulkan API publicly released.

  • 2016-03-06 vulkan-go initial commit and first binding.

  • 2016-05-14 Finally received my NVIDIA Shield Tablet K1 (DHL lost the first parcel), I decided to use tablet because it was the first device supporting Vulkan out of the box. And that was a really good implementation, much wow very reference.

  • 2016-05-17 Created android-go project in order to run Vulkan on the android platform.

  • 2016-05-23 First android-go + vulkan program runs on Tablet K1 (screenshot).

  • 2016-05-24 Improved VulkanInfo example runs on Tablet K1 (screenshot).

  • 2016-05-28 android-go released into public (Reddit post) with plenty of examples including GLES/EGL.

  • 2016-08-13 Finished an app that should draw triangle (ported from tri.c from LunarG demos). Draws nothing instead.

  • 2016-08-13 First unsuccessful attempt to write a spinning cube example. More than 25 hours spent, 2.5k lines of C code rewritten into 900 lines of Go code. The reference code was found in some very old LunarG demo, it seems I should've used the latest one.. At least got the validation layers working and found some bugs in the triangle app code.

  • 2016-08-16 First Vulkan API program in Go that draws triangle runs on Tablet K1 (photo), validaton layers work perfectly too.

  • 2016-08-16 Public announce of this project (Reddit post). Reaction was "Meh".

  • 2016-11-01 MoltenVK driver merged into GLFW (see GLFW issue #870) and this made possible to use Vulkan API under Apple OS X or macOS.

  • 2016-11-06 VulkanInfo and VulkanDraw both ported to desktop OS X and use GLFW to initialize Vulkan (screen #1 and screen #2)

  • 2016-11-07 VulkanInfo and VulkanDraw run fine on NVIDIA GTX980 initialized through GLFW under Windows 10 (screen #1 and screen #2).

  • 2016-11-08 VulkanInfo runs in headless (a.k.a computing) mode in Amazon AWS cloud on P2 Instance equipped Tesla K80 (screenshot).

  • 2016-11-09 ios-go project started, it's very easy to run Golang apps on iOS that use custom surface, for my case it was Metal surface.

  • 2016-11-11 VulkanInfo runs fine on my iPhone under iOS (screenshot), and so does VulkanDraw (photo also GPU report from XCode)

  • 2016-11-13 Second unsuccessful attempt to write spinning cube. 25 hours spent. The approach was highly inspired by Mali Vulkan SDK for Android 1.0 and I created initial version of vulkan-go/asche — a higher level framework to simplify Vulkan initialization for new apps.

  • 2016-11-29 Generic Linux support added in using GLFW (Issue #2) thanks @jfreymuth.

  • 2017-05-06 Third, successful attempt to write spining cube example. 16 hours spent, 4K LOC of C code rewritten from cube.c of LunarG demos. The whole process has been screencasted, maybe I will release it one day.

  • 2017-05-06 vulkan-go/asche complete.

  • 2018-10-13 Updated to Vulkan 1.1.88 spec.

vulkan cube golang

See all demos in vulkan-go/demos.

How to use

Usage of this project is straightforward due to the stateless nature of Vulkan API. Just import the package like this:

import vk "github.com/vulkan-go/vulkan"

Set the GetProcAddress pointer (used to look up Vulkan functions) using SetGetInstanceProcAddr or SetDefaultGetInstanceProcAddr. After that you can call Init to initialise the library. For example:

// Using SDL2:
vk.SetGetInstanceProcAddr(sdl.VulkanGetVkGetInstanceProcAddr())

// OR using GLFW:
vk.SetGetInstanceProcAddr(glfw.GetVulkanGetInstanceProcAddress())

// OR without using a windowing library (Linux only, recommended for compute-only tasks)
if err := vk.SetDefaultGetInstanceProcAddr(); err != nil {
    panic(err)
}

if err := vk.Init(); err != nil {
    panic(err)
}

And you're set. I must warn you that using the API properly is not an easy task at all, so beware and follow the official documentation: https://www.khronos.org/registry/vulkan/specs/1.0/html/vkspec.html

In order to simplify development, I created a high-level framework that manages Vulkan platform state and initialization. It is called asche because when you throw a gopher into volcano you get a pile of ash. Currently it's used in VulkanCube demo app.

Validation Layers

A good brief of the current state of Vulkan validation layers: Explore the Vulkan Loader and Validation Layers (PDF).

There is a full support of validation layers with custom callbacks in Go. For my Android experiments I got the standard pack of layers from https://github.com/LunarG/VulkanTools and built them like this:

$ cd build-android
$ ./update_external_sources_android.sh
$ ./android-generate.sh
$ ndk-build

After that you'd copy the objects to android/jni/libs in your project and activate the ValidationLayers.mk in your Android.mk so when building APK they will be copied alongside with your shared library. It just works then:

[INFO] Instance extensions: [VK_KHR_surface VK_KHR_android_surface]
[INFO] Instance layers: [VK_LAYER_LUNARG_screenshot VK_LAYER_GOOGLE_unique_objects VK_LAYER_LUNARG_api_dump VK_LAYER_LUNARG_image VK_LAYER_LUNARG_core_validation VK_LAYER_LUNARG_object_tracker VK_LAYER_GOOGLE_threading VK_LAYER_LUNARG_parameter_validation VK_LAYER_LUNARG_swapchain]

[Layer Swapchain][ERROR 4] The surface in pCreateInfo->surface, that was given to vkCreateSwapchainKHR(), must be a surface that is supported by the device as determined by vkGetPhysicalDeviceSurfaceSupportKHR().  However, vkGetPhysicalDeviceSurfaceSupportKHR() was never called with this surface.

[Layer Swapchain][ERROR 10] vkCreateSwapchainKHR() called with a non-supported pCreateInfo->compositeAlpha (i.e. VK_COMPOSITE_ALPHA_OPAQUE_BIT_KHR).  Supported values are:
     VK_COMPOSITE_ALPHA_INHERIT_BIT_KHR

[Layer DS][ERROR 8] Attempt to set lineWidth to 0.000000 but physical device wideLines feature not supported/enabled so lineWidth must be 1.0f!

[Layer DS][ERROR 22] Unable to allocate 2 descriptors of type VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER from pool 0x1c. This pool only has 1 descriptors of this type remaining.

Useful links

License

MIT

Comments
  • Please provide Stuffs needed cube to run on wayland linux

    Please provide Stuffs needed cube to run on wayland linux

    Recently I got running the go-wayland-cube demo on Nvidia on Wayland Ubuntu Linux. This fixed the last big gpu vendor (Intel, Amd worked fine).

    I've used egl-wayland-1.1.11, and driver was 515.65.01

    The things missing from your awesome vulkan package to make this work are available in the vulkan/ subdir of my repo github.com/neurlang/wayland/tree/master/vulkan

    Please consider adding those things to your repo, because it's really vulkan related and should be provided by you. Thanks.

  • build error under OSX 10.12.6

    build error under OSX 10.12.6

    Hi, with the official deprecation announcement of OpenGL for OSX, I started looking into this exiciting project, but am getting struck down cold by the very first initial step:

    go get -u github.com/vulkan-go/demos/vulkancube
    # github.com/vulkan-go/vulkan
    ld: warning: text-based stub file /System/Library/Frameworks//QuartzCore.framework/QuartzCore.tbd and library file /System/Library/Frameworks//QuartzCore.framework/QuartzCore are out of sync. Falling back to library file for linking.
    ld: framework not found MoltenVK
    clang: error: linker command failed with exit code 1 (use -v to see invocation)
    # github.com/vulkan-go/vulkan
    vk_wrapper_desktop.c:11:12: warning: implicit declaration of function 'glfwCreateWindowSurface' is invalid in C99 [-Wimplicit-function-declaration]
    vk_wrapper_desktop.c:18:51: warning: implicit declaration of function 'glfwGetInstanceProcAddress' is invalid in C99 [-Wimplicit-function-declaration]
    ...
    (dozens of other warnings)
    

    I just have built MoltenVK and verified it works by running some demos, but it doesn't seem their build process installs the framework globally. Do you have any docs or config options for a) installing that framework for vulkan-go to find and/or b) specify library/include paths for vulkan-go to search in? Thanks!

  • Help! What do I need to do to get coding with Vulkan?

    Help! What do I need to do to get coding with Vulkan?

    I'm pretty new to Go and programming in general. I am really interested to get working with Vulkan in Go but I don't know where to start. I understand that Vulkan and some other Go packages use C code behind the scenes and this requires a different compiler. But I don't know what to get, how to install it, etc. What programs do I need to install? I currently have Go 1.9.4 windows/amd64 When I start coding a new project, where do I put the files and how to I configure them? How do I compile and run a program?

    I tried figuring it out myself but I simply don't know what I need and I couldn't find a source that has all this information. Thank you for the help!

  • vulkan.CreateInstance throws runtime error

    vulkan.CreateInstance throws runtime error

    Calling CreateInstance panics with runtime error: cgo argument has Go pointer to Go pointer.

    appInfo := &vk.ApplicationInfo{
    	SType:              vk.StructureTypeApplicationInfo,
    	PApplicationName:   title,
    	ApplicationVersion: vk.MakeVersion(0, 0, 0),
    	PEngineName:        "No Engine",
    	EngineVersion:      vk.MakeVersion(0, 0, 0),
    	ApiVersion:         vk.ApiVersion10,
    }
    createInfo := &vk.InstanceCreateInfo{
    	SType:            vk.StructureTypeInstanceCreateInfo,
    	PApplicationInfo: appInfo,
    }
    
    if ret := vk.CreateInstance(createInfo, nil, &vkInstance); ret != vk.Success {
    	return errors.New("failed to create Vulkan instance")
    }
    
    panic: runtime error: cgo argument has Go pointer to Go pointer
    
    goroutine 1 [running]:
    github.com/vulkan-go/vulkan.CreateInstance.func1(0x1b10470, 0x0, 0x785048, 0xc4200b2060)
            /home/vhns/projects/go/src/github.com/vulkan-go/vulkan/vulkan.go:24 +0xa2
    github.com/vulkan-go/vulkan.CreateInstance(0xc420069ea8, 0x0, 0x785048, 0xa)
            /home/vhns/projects/go/src/github.com/vulkan-go/vulkan/vulkan.go:24 +0x4d
    gitlab.com/jclc/game/graphics.Init(0x4f4e7f, 0xa, 0xc4200b0020, 0x5073a0)
            /home/vhns/projects/go/src/gitlab.com/jclc/game/graphics/vulkan.go:51 +0x19e
    main.main()
            /home/vhns/projects/go/src/gitlab.com/jclc/game/main.go:12 +0x3a
    exit status 2
    
  • fails to build on Ubuntu 16.10

    fails to build on Ubuntu 16.10

    Just trying to install this library with "go get", and it's having problems finding all the function definitions for the C Vulkan library:

    $ go get -v github.com/vulkan-go/vulkan
    github.com/vulkan-go/vulkan
    # github.com/vulkan-go/vulkan
    /tmp/go-build113185610/github.com/vulkan-go/vulkan/_obj/init.cgo2.o: In function `_cgo_2f542f46001b_Cfunc_vkInit':
    ../../../go/src/github.com/vulkan-go/vulkan/init.go:50: undefined reference to `vkInit'
    /tmp/go-build113185610/github.com/vulkan-go/vulkan/_obj/init.cgo2.o: In function `_cgo_2f542f46001b_Cfunc_vkInitInstance':
    ../../../go/src/github.com/vulkan-go/vulkan/init.go:68: undefined reference to `vkInitInstance'
    /tmp/go-build113185610/github.com/vulkan-go/vulkan/_obj/vk_bridge.o: In function `callVkCreateInstance':
    ../../../go/src/github.com/vulkan-go/vulkan/vk_bridge.c:8: undefined reference to `vgo_vkCreateInstance'
    /tmp/go-build113185610/github.com/vulkan-go/vulkan/_obj/vk_bridge.o: In function `callVkDestroyInstance':
    ../../../go/src/github.com/vulkan-go/vulkan/vk_bridge.c:14: undefined reference to `vgo_vkDestroyInstance'
    /tmp/go-build113185610/github.com/vulkan-go/vulkan/_obj/vk_bridge.o: In function `callVkEnumeratePhysicalDevices':
    ../../../go/src/github.com/vulkan-go/vulkan/vk_bridge.c:21: undefined reference to `vgo_vkEnumeratePhysicalDevices'
    [...]
    

    It doesn't seem to be resolving the headers properly, either the system ones (via libvulkan-dev package) or via the header files you've included in the repo under /vulkan. Any ideas?

  • Add a package with bindings for VulkanMemoryAllocator

    Add a package with bindings for VulkanMemoryAllocator

    The Vulkan spec doesn't require the driver to handle memory allocation, leaving the user with the responsibility to deal with the memory management. For most use cases however, the VulkanMemoryAllocator library is sufficient. Would be nice having it included with the Vulkan bindings, perhaps under a subpackage called vma.

  • Not able to use dep to isolate vulkan dependency

    Not able to use dep to isolate vulkan dependency

    Have a working example using go get, go run main.go works fine.

    Use dep init to pull the same dependencies to the vendor folder.

      Using master as constraint for direct dep github.com/vulkan-go/vulkan
      Locking in master (f7f4611) for direct dep github.com/vulkan-go/vulkan
      Using ^0.8.0 as constraint for direct dep github.com/pkg/errors
      Locking in v0.8.0 (645ef00) for direct dep github.com/pkg/errors
      Using v3.3 as constraint for direct dep github.com/vulkan-go/glfw
      Locking in v3.3 (72ceac6) for direct dep github.com/vulkan-go/glfw
    

    It appears there is bad path resolution happening.

    # learn/vendor/github.com/vulkan-go/glfw/v3.3/glfw
    vendor\github.com\vulkan-go\glfw\v3.3\glfw\c_glfw.go:4:30: fatal error: glfw/src/context.c: No such file or directory
    compilation terminated.
    # learn/vendor/github.com/vulkan-go/vulkan
    vendor\github.com\vulkan-go\vulkan\cgo_helpers.go:10:27: fatal error: vulkan/vulkan.h: No such file or directory
    compilation terminated.
    
  • PhysicalDeviceProperties -> Limits, all values returned from GetPhysicalDeviceProperties() are set to 0

    PhysicalDeviceProperties -> Limits, all values returned from GetPhysicalDeviceProperties() are set to 0

    Hey! Thanks for great library!

    I spotted the following issue with this lib. today on macOS. When I call GetPhysicalDeviceProperties(), I can get other properties like DeviceName, VendorID of PhysicalDeviceProperties just fine, but the embedded Limits structure has all values set to 0.

    I'm not sure if this is my local problem or it's just a bug?

    {MaxImageDimension1D:0 MaxImageDimension2D:0 MaxImageDimension3D:0 MaxImageDimensionCube:0 MaxImageArrayLayers:0 MaxTexelBufferElements:0 MaxUniformBufferRange:0 MaxStorageBufferRange:0 MaxPushConstantsSize:0 MaxMemoryAllocationCount:0 MaxSamplerAllocationCount:0 BufferImageGranularity:0 SparseAddressSpaceSize:0 MaxBoundDescriptorSets:0 MaxPerStageDescriptorSamplers:0 MaxPerStageDescriptorUniformBuffers:0 MaxPerStageDescriptorStorageBuffers:0 MaxPerStageDescriptorSampledImages:0 MaxPerStageDescriptorStorageImages:0 MaxPerStageDescriptorInputAttachments:0 MaxPerStageResources:0 MaxDescriptorSetSamplers:0 MaxDescriptorSetUniformBuffers:0 MaxDescriptorSetUniformBuffersDynamic:0 MaxDescriptorSetStorageBuffers:0 MaxDescriptorSetStorageBuffersDynamic:0 MaxDescriptorSetSampledImages:0 MaxDescriptorSetStorageImages:0 MaxDescriptorSetInputAttachments:0 MaxVertexInputAttributes:0 MaxVertexInputBindings:0 MaxVertexInputAttributeOffset:0 MaxVertexInputBindingStride:0 MaxVertexOutputComponents:0 MaxTessellationGenerationLevel:0 MaxTessellationPatchSize:0 MaxTessellationControlPerVertexInputComponents:0 MaxTessellationControlPerVertexOutputComponents:0 MaxTessellationControlPerPatchOutputComponents:0 MaxTessellationControlTotalOutputComponents:0 MaxTessellationEvaluationInputComponents:0 MaxTessellationEvaluationOutputComponents:0 MaxGeometryShaderInvocations:0 MaxGeometryInputComponents:0 MaxGeometryOutputComponents:0 MaxGeometryOutputVertices:0 MaxGeometryTotalOutputComponents:0 MaxFragmentInputComponents:0 MaxFragmentOutputAttachments:0 MaxFragmentDualSrcAttachments:0 MaxFragmentCombinedOutputResources:0 MaxComputeSharedMemorySize:0 MaxComputeWorkGroupCount:[0 0 0] MaxComputeWorkGroupInvocations:0 MaxComputeWorkGroupSize:[0 0 0] SubPixelPrecisionBits:0 SubTexelPrecisionBits:0 MipmapPrecisionBits:0 MaxDrawIndexedIndexValue:0 MaxDrawIndirectCount:0 MaxSamplerLodBias:0 MaxSamplerAnisotropy:0 MaxViewports:0 MaxViewportDimensions:[0 0] ViewportBoundsRange:[0 0] ViewportSubPixelBits:0 MinMemoryMapAlignment:0 MinTexelBufferOffsetAlignment:0 MinUniformBufferOffsetAlignment:0 MinStorageBufferOffsetAlignment:0 MinTexelOffset:0 MaxTexelOffset:0 MinTexelGatherOffset:0 MaxTexelGatherOffset:0 MinInterpolationOffset:0 MaxInterpolationOffset:0 SubPixelInterpolationOffsetBits:0 MaxFramebufferWidth:0 MaxFramebufferHeight:0 MaxFramebufferLayers:0 FramebufferColorSampleCounts:0 FramebufferDepthSampleCounts:0 FramebufferStencilSampleCounts:0 FramebufferNoAttachmentsSampleCounts:0 MaxColorAttachments:0 SampledImageColorSampleCounts:0 SampledImageIntegerSampleCounts:0 SampledImageDepthSampleCounts:0 SampledImageStencilSampleCounts:0 StorageImageSampleCounts:0 MaxSampleMaskWords:0 TimestampComputeAndGraphics:0 TimestampPeriod:0 MaxClipDistances:0 MaxCullDistances:0 MaxCombinedClipAndCullDistances:0 DiscreteQueuePriorities:0 PointSizeRange:[0 0] LineWidthRange:[0 0] PointSizeGranularity:0 LineWidthGranularity:0 StrictLines:0 StandardSampleLocations:0 OptimalBufferCopyOffsetAlignment:0 OptimalBufferCopyRowPitchAlignment:0 NonCoherentAtomSize:0 ref7926795a:0x46f55728 allocs7926795a:<nil>}

  • vulkan.CreateDevice throws runtime panic

    vulkan.CreateDevice throws runtime panic

    I'm trying to create a device via

    dqci := []vk.DeviceQueueCreateInfo{{
    		SType:            vk.StructureTypeDeviceQueueCreateInfo,
    		QueueFamilyIndex: v.graphicsIdx,
    		QueueCount:       1,
    		PQueuePriorities: []float32{1.0},
    }}
    ci := vk.DeviceCreateInfo{
    	SType:                   vk.StructureTypeDeviceCreateInfo,
    	PQueueCreateInfos:       dqci,
    	QueueCreateInfoCount:    uint32(len(dqci)),
    	EnabledExtensionCount:   uint32(len(v.enabledExtensions)),
    	PpEnabledExtensionNames: safeStrings(v.enabledExtensions),
    	EnabledLayerCount:       0,
    }
    if res := vk.CreateDevice(v.pd, &ci, nil, &v.d); res != vk.Success {
    	return errors.New("unable to create device")
    }
    

    which looks almost exactly what you have in asche. However, I am getting a runtime panic when I try it

    [mvk-info] MoltenVK version 1.0.10. Vulkan version 1.0.75.
    [mvk-info] GPU device:
    		model: Intel(R) Iris(TM) Plus Graphics 640
    		type: Integrated
    		vendorID: 0x8086
    		deviceID: 0x5926
    		pipelineCacheUUID: 00000000-0000-0000-0000-27130000271A
    	supports the following Metal Feature Sets:
    		macOS GPU Family 1 v3
    		macOS GPU Family 1 v2
    		macOS GPU Family 1 v1
    panic: runtime error: cgo argument has Go pointer to Go pointer
    	panic: runtime error: index out of range
    
    goroutine 1 [running, locked to thread]:
    main.(*vulkanApp).cleanup(0xc00008a000)
    	/Users/noofapple/go/src/vulkanPlay/main.go:822 +0x331
    panic(0x4402220, 0xc000010440)
    	/usr/local/go/src/runtime/panic.go:513 +0x1b9
    github.com/vulkan-go/vulkan.CreateDevice.func1(0x5074410, 0x4a71d70, 0x0, 0xc00008a038, 0x0)
    	/Users/noofapple/go/src/github.com/vulkan-go/vulkan/vulkan.go:104 +0xcd
    github.com/vulkan-go/vulkan.CreateDevice(0x5074410, 0xc000045e48, 0x0, 0xc00008a038, 0x1)
    	/Users/noofapple/go/src/github.com/vulkan-go/vulkan/vulkan.go:104 +0x57
    main.(*vulkanApp).createLogicalDevice(0xc00008a000, 0x0, 0x0)
    	/Users/noofapple/go/src/vulkanPlay/main.go:151 +0x19d
    main.(*vulkanApp).initVulkan(0xc00008a000, 0x0, 0x0)
    	/Users/noofapple/go/src/vulkanPlay/main.go:100 +0x92
    main.(*vulkanApp).run(0xc00008a000, 0x0, 0x0)
    	/Users/noofapple/go/src/vulkanPlay/main.go:60 +0x82
    main.main()
    	/Users/noofapple/go/src/vulkanPlay/main.go:873 +0x3b
    exit status 2
    

    This has worked for me before, but trying to run it today is causing this problem. I've tried printing all the things passed to make sure okay and it looks fine. Anyone have any tips or advice?

    ETA: The second panic, index out of range, is in the cleanup step and there's no fences to cleanup since they're created after the device is created which is where the first panic happens.

  • Missing an LDFLAGS directive on Linux/Unix

    Missing an LDFLAGS directive on Linux/Unix

    First of all, love the refactoring; the repository is looking much nicer now without the different source files for each of the desktop platforms. We should strive for as little platform-specific code as possible. However, when the Linux source file was deleted, the cgo directive for linking with dl was also removed, preventing building.

    go get -u -v github.com/vulkan-go/vulkan
    github.com/vulkan-go/vulkan (download)
    github.com/vulkan-go/vulkan
    # github.com/vulkan-go/vulkan
    /usr/bin/ld: $WORK/b001/_x010.o: in function `getDefaultProcAddr':
    vulkan-go/vulkan/vk_default_loader.c:26: undefined reference to `dlopen'
    /usr/bin/ld: vulkan-go/vulkan/vk_default_loader.c:30: undefined reference to `dlsym'
    collect2: error: ld returned 1 exit status
    

    A simple solution is to just add #cgo linux LDFLAGS: -ldl in vulkan.go, but that file is autogenerated. Could the line just be added in the generator? I'm not familiar with the bindings generator. Adding a new file just for that one directive would be a little ugly in my opinion, but maybe it would be the better choice? Otherwise you'd have to regen the bindings every time you change the build/link flags.

  • Conditional compilation to target Apple Metal API

    Conditional compilation to target Apple Metal API

    As I understand it, to work on osx and iOS, we need to by "Molten" that is code that maps Vulkan calls to Aple's Metal API ?

    I have not looked too deeply into this but historically Metal was a fork of Vulkan. Apple Just can't help itself :)

    So, it maybe possible to use some conditional compilation to bypass Molten and target Metal direct ?

    I am guessing you have also thought about this too but am raising it here to gather ideas / approaches .

    This is super awesome project btw. Thank you so much for this work.

  • vulkancube_glfw make

    vulkancube_glfw make

    MoltenVK installed: C02F32EDML85:vulkancube_glfw bytedance$ ls /usr/local/lib/MoltenVK/ MoltenVK.xcframework dylib include

    run: C02F32EDML85:vulkancube_glfw bytedance$ make CGO_CFLAGS="-I"/usr/local/Cellar/glfw/3.3.7/include"" CGO_LDFLAGS="-L"/usr/local/Cellar/glfw/3.3.7/lib"" go install

    error:

    github.com/vulkan-go/vulkan

    ld: framework not found MoltenVK clang: error: linker command failed with exit code 1 (use -v to see invocation)

    github.com/vulkan-go/glfw/v3.3/glfw

    ld: framework not found MoltenVK clang: error: linker command failed with exit code 1 (use -v to see invocation)

    github.com/vulkan-go/glfw/v3.3/glfw

    In file included from ../../../../../pkg/mod/github.com/vulkan-go/[email protected]/v3.3/glfw/c_glfw_darwin.go:8: ../../../../../pkg/mod/github.com/vulkan-go/[email protected]/v3.3/glfw/glfw/src/cocoa_window.m:1027:9: warning: multiple methods named 'center' found [-Wobjc-multiple-method-names] /Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/System/Library/Frameworks/AppKit.framework/Headers/NSCollectionViewCompositionalLayout.h:604:19: note: using /Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/System/Library/Frameworks/AppKit.framework/Headers/NSWindow.h:341:1: note: also found make: *** [install] Error 2

  • Null-terminate go strings

    Null-terminate go strings

    If possible, I would like if the package would automatically append a null terminator where appropriate converting from go strings to c strings.

    An example of the current behavior when creating a vulkan instance demonstrates my problem:

    instanceExtensions := []string{
        vk.KhrSurfaceExtensionName, // Note - using constant defined by the package
    }
    instanceCreateInfo := &vk.InstanceCreateInfo{
        SType: vk.StructureTypeInstanceCreateInfo,
        PApplicationInfo: appInfo,
        EnabledExtensionCount: uint32(len(instanceExtensions)),
        PpEnabledExtensionNames: instanceExtensions,
    }
    err := vk.Error(vk.CreateInstance(instanceCreateInfo, nil, &v.instance)) // vulkan error: extension not present
    

    I would like if using the constant vk.KhrSurfaceExtensionName or replacing it with its literal value "VK_KHR_surface" would both succeed without the need to append a null character, e.g. "VK_KHR_surface\x00", though I feel at a minimum the package constants should succeed without having to append the null-terminator at runtime.

    This would also assist with GLFW integration, since GetRequiredInstanceExtensions() in the go-gl/glfw package does not return null-terminated values either, and would mitigate a current unexpected behavior if attempting to use vk.ToString() to test if an extension is supported, demonstrated below:

    extensionCount := uint32(0)
    vk.EnumerateInstanceExtensionProperties("", &extensionCount, nil)
    supportedExtensions := make([]vk.ExtensionProperties, extensionCount)
    vk.EnumerateInstanceExtensionProperties("", &extensionCount, supportedExtensions)
    
    debugFound := false
    for _, extProps := range supportedExtensions {
        if vk.ToString(extProps.ExtensionName == "VK_EXT_debug_utils" {
            // False positive: can cause runtime exception if used to test if extension is supported before calling CreateInstance
            debugFound = true
            break
        }
    
        if vk.ToString(extProps.ExtensionName) == "VK_EXT_debug_utils\x00" {
            // Unreachable since ToString() trims the null terminator
            debugFound = true
            break
        }
    }
    

    You can see that the above code will give the wrong result regardless of if the test string is null-terminated or not, causing the need to manually append a null-terminator to the test string after running this test or to write a custom ToString method.

  •  fatal: repository 'https://github.com/xlab/linmath-go/' not found

    fatal: repository 'https://github.com/xlab/linmath-go/' not found

    When trying to run vulkancube or vulkandraw, I get

    go: finding module for package github.com/xlab/closer
    go: finding module for package github.com/vulkan-go/vulkan
    go: finding module for package github.com/vulkan-go/asche
    go: finding module for package github.com/vulkan-go/demos/vulkancube
    go: finding module for package github.com/vulkan-go/glfw/v3.3/glfw
    go: found github.com/vulkan-go/asche in github.com/vulkan-go/asche v0.0.0-20190912134304-d4b318b67e07
    go: found github.com/vulkan-go/demos/vulkancube in github.com/vulkan-go/demos v0.0.0-20200912085326-922fc3db80c5
    go: found github.com/vulkan-go/glfw/v3.3/glfw in github.com/vulkan-go/glfw v0.0.0-20210402172934-58379a80228d
    go: found github.com/vulkan-go/vulkan in github.com/vulkan-go/vulkan v0.0.0-20210402152248-956e3850d8f9
    go: found github.com/xlab/closer in github.com/xlab/closer v0.0.0-20190328110542-03326addb7c2
    go: finding module for package github.com/xlab/linmath-go/linmath
    go: finding module for package github.com/stretchr/testify/assert
    go: found github.com/stretchr/testify/assert in github.com/stretchr/testify v1.7.0
    go: finding module for package github.com/xlab/linmath-go/linmath
    cube imports
            github.com/vulkan-go/asche imports
            github.com/xlab/linmath tested by
            github.com/xlab/linmath.test imports
            github.com/xlab/linmath-go/linmath: cannot find module providing package github.com/xlab/linmath-go/linmath: module github.com/xlab/linmath-go/linmath: git ls-remote -q origin in /Users/nishant/go/pkg/mod/cache/vcs/97833a51e0eb989d3a7ed868526b7c9da4576ae8e9721796c4eaad8eb994ea79: exit status 128:
            remote: Repository not found.
            fatal: repository 'https://github.com/xlab/linmath-go/' not found
    
  • SetDefaultGetInstanceProcAddr doesn't work on MacOS

    SetDefaultGetInstanceProcAddr doesn't work on MacOS

    Using SetDefaultGetInstanceProcAddr on MacOS just causes the error vulkan: error loading default getProcAddr. This is because:

    1. First, this function calls setDefaultProcAddr https://github.com/vulkan-go/vulkan/blob/956e3850d8f9d2e617caf5a60622c638ff729c2b/init.go#L22
    2. In setDefaultProcAddr, it calls getDefaultProcAddr https://github.com/vulkan-go/vulkan/blob/956e3850d8f9d2e617caf5a60622c638ff729c2b/vk_wrapper_desktop.c#L14
    3. In getDefaultProcAddr, for MacOS, it just returns NULL https://github.com/vulkan-go/vulkan/blob/956e3850d8f9d2e617caf5a60622c638ff729c2b/vk_default_loader.c#L35-L37
    4. In SetDefaultGetInstanceProcAddr, it checks for isProcAddrSet https://github.com/vulkan-go/vulkan/blob/956e3850d8f9d2e617caf5a60622c638ff729c2b/init.go#L23-L25
    5. In isProcAddrSet, it checks if it is equal to NULL https://github.com/vulkan-go/vulkan/blob/956e3850d8f9d2e617caf5a60622c638ff729c2b/vk_wrapper_desktop.c#L18

    Therefore, on MacOS, isProcAddrSet will always return false. Why is it like this? Is there a way to get around this error? If you ignore it, you just get an error about proc addr not being set in Init.

  • DeviceCreateInfo.PEnabledFeatures should be a pointer, not a slice.

    DeviceCreateInfo.PEnabledFeatures should be a pointer, not a slice.

    The Vulkan documentation for DeviceCreateInfo states that

    pEnabledFeatures is NULL or a pointer to a VkPhysicalDeviceFeatures structure containing boolean indicators of all the features to be enabled.

    But the currently generated DeviceCreateInfo has a slice instead of a pointer for the PEnabledFeatures field.

    Is this a matter of adding another hint into struct section of vulkan.yml

Cgo bindings to PulseAudio's Simple API, for easily playing or capturing raw audio.

pulse-simple Cgo bindings to PulseAudio's Simple API, for easily playing or capturing raw audio. The full Simple API is supported, including channel m

Dec 17, 2022
The android-go project provides a platform for writing native Android apps in Go programming language.
The android-go project provides a platform for writing native Android apps in Go programming language.

android-go The android-go project aims to provide a platform (namely an SDK) for writing native Android apps in Go programming language. All things he

Jan 5, 2023
Image resizing for the Go programming language with common interpolation methods

This package is no longer being updated! Please look for alternatives if that bothers you. Resize Image resizing for the Go programming language with

Dec 14, 2021
Go bindings for GLFW 3

GLFW 3.3 for Go Installation GLFW C library source is included and built automatically as part of the Go package. But you need to make sure you have d

Jan 8, 2023
Go bindings for GLFW 3

GLFW 3.3 for Go Installation GLFW C library source is included and built automatically as part of the Go package. But you need to make sure you have d

Dec 25, 2022
Go bindings for OpenGL (generated via glow)

gl This repository holds Go bindings to various OpenGL versions. They are auto-generated using Glow. Features: Go functions that mirror the C specific

Dec 12, 2022
Go bindings to OpenGL Utility Library

GLU This package offers minimal bindings for GLU functions. Usage go get github.com/go-gl-legacy/glu License Copyright 2012 The go-gl Authors. All ri

Aug 18, 2018
Go bindings for audio capture and playback with ALSA and libasound

Go ALSA bindings These bindings allow capture and playback of audio via ALSA using the alsa-lib library. Installation go get github.com/cocoonlife/goa

Nov 26, 2022
naive go bindings to GnuPlot
naive go bindings to GnuPlot

go-gnuplot Simple-minded functions to work with gnuplot. go-gnuplot runs gnuplot as a subprocess and pushes commands via the STDIN of that subprocess.

Nov 8, 2021
go-gtk3 - GTK3 BINDINGS FOR GO

go-gtk3 - GTK3 BINDINGS FOR GO THIS IS: Hopefully GTK3 Bindings using gobject binding for Go. Goal is to have fairly complete gtk3 widgets with pango

May 25, 2021
Experimental OpenAL bindings for Go.

Experimental OpenAL bindings for Go. ==================================== Everything is evolving quickly and nothing is totally done. If you want to

Jul 24, 2022
Go bindings for GStreamer (retired: currently I don't use/develop this package)

Retired. I don't use/develop this package anymore. Go bindings for GStreamer at a very early stage of maturity. This package is based on GLib bindings

Nov 10, 2022
Go bindings for libVLC and high-level media player interface
Go bindings for libVLC and high-level media player interface

Go bindings for libVLC 2.X/3.X/4.X and high-level media player interface. The package can be useful for adding multimedia capabilities to applications

Dec 31, 2022
Go bindings for OpenCV1.1 (Dev/Zero Dependencies).
Go bindings for OpenCV1.1 (Dev/Zero Dependencies).

Go语言QQ群: 102319854, 1055927514 凹语言(凹读音“Wa”)(The Wa Programming Language): https://github.com/wa-lang/wa Go bindings for OpenCV1.1 PkgDoc: http://godoc

Dec 6, 2022
Go cross-platform OpenGL bindings.

gl Package gl is a Go cross-platform binding for OpenGL, with an OpenGL ES 2-like API. It supports: macOS, Linux and Windows via OpenGL 2.1 backend, i

Nov 21, 2022
go library for image programming (merge, crop, resize, watermark, animate, ease, transit)
go library for image programming (merge, crop, resize, watermark, animate, ease, transit)

Result Terminal Code mergi -t TT -i https://raw.githubusercontent.com/ashleymcnamara/gophers/master/Facepalm_Gopher.png -r "131 131" -i https://raw.gi

Jan 6, 2023
A pair programming service using operational transforms
A pair programming service using operational transforms

Leaps is a service for collaboratively editing your local files over a web UI, using operational transforms to ensure zero-collision synchronization a

Dec 7, 2022
Go Language Library for SVG generation
Go Language Library for SVG generation

SVGo: A Go library for SVG generation The library generates SVG as defined by the Scalable Vector Graphics 1.1 Specification (http://www.w3.org/TR/SVG

Jan 6, 2023
Avatar generation library for GO language
Avatar generation library for GO language

GOvatar GOvatar is an avatar generation library written in GO Install To install the library and command-line program, use the following: $ go get -u

Dec 29, 2022