{"id":16254305,"url":"https://github.com/celer/vkg","last_synced_at":"2025-10-03T14:59:48.624Z","repository":{"id":57505185,"uuid":"231270639","full_name":"celer/vkg","owner":"celer","description":"Vulkan Go API to soothe the soul","archived":false,"fork":false,"pushed_at":"2020-01-09T23:53:58.000Z","size":298,"stargazers_count":2,"open_issues_count":1,"forks_count":1,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-08-18T07:27:23.087Z","etag":null,"topics":["3d","golang","vulkan"],"latest_commit_sha":null,"homepage":null,"language":"Go","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/celer.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2020-01-01T22:26:24.000Z","updated_at":"2021-12-10T20:20:36.000Z","dependencies_parsed_at":"2022-08-22T08:50:25.284Z","dependency_job_id":null,"html_url":"https://github.com/celer/vkg","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/celer/vkg","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/celer%2Fvkg","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/celer%2Fvkg/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/celer%2Fvkg/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/celer%2Fvkg/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/celer","download_url":"https://codeload.github.com/celer/vkg/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/celer%2Fvkg/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":278180004,"owners_count":25943400,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","status":"online","status_checked_at":"2025-10-03T02:00:06.070Z","response_time":53,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["3d","golang","vulkan"],"created_at":"2024-10-10T15:21:02.410Z","updated_at":"2025-10-03T14:59:48.593Z","avatar_url":"https://github.com/celer.png","language":"Go","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Intro\n\nThis repo is very much a work in progress of utilizing Vulkan with go. I've wrapped the vulkan-go/vulkan APIs to make\nthem a little more idiomatic, and easier to use and also provided a bunch of utility classes. \n\nHere is where I'm at:\n\n  * Provides an easier to use API than the native Vulkan APIs\n  * Provides for access to all underlying vulkan data structures, so it makes things easy without hiding the necessary bits to utilize the full vulkan API\n  * Works with ImGUI\n  * Custom memory allocator see allocator.go\n  * Utility class called GraphicsApp which does most of the bootstrapping required to get a vulkan app up and going\n  * Can display meshes and textures\n  \nIf you want to get a good idea of where I'm going checkout examples/imgui\n\nHere is where I expect to go;\n\n  * More documentation\n  * More examples\n  * Unit tests\n\nI'm hoping to continue pushing on this repo more in the next few weeks. \n\n# Screenshots\n\nHere is a picture of the examples/imgui program:\n\n![Example program](/assets/imgui.png)\n\nHere is a picture of the examples/texture program:\n\n![Example program](/assets/texture.png)\n\n\n# Quick example code\n\n[Here is the example this code comes from](/examples/cube/cube.go)\n\nHow to initialize a new graphics app:\n```go\n// we initialize glfw, so we can create a window\nglfw.Init()\n\n// setup vulkan\nvk.SetGetInstanceProcAddr(glfw.GetVulkanGetInstanceProcAddress())\nvk.Init()\n\n// create our window\nglfw.WindowHint(glfw.ClientAPI, glfw.NoAPI)\nc.window, _ = glfw.CreateWindow(Width, Height, \"VulkanCube\", nil, nil)\n\n// create a new graphics app\nc.app, _ = vkg.NewGraphicsApp(\"VulkanCube\", vkg.Version{1, 0, 0})\n\n// we need to do some configuration before we can\n// can initalize our application\nc.app.SetWindow(c.window)\nc.app.EnableDebugging()\n\n// initialize our graphics app\nc.app.Init()\n```\n\nHow to create memory resources from allocated pools\n\n```go\n// we allocate a new memory pool, with the size we calculated above, and we tell vulkan where we'd like to store the data\n// in this case we're gonna store all our data in the host's memory and use a memory map to sync the data to the GPU\n// so we specify HostVisible|HostCoherent to make sure we can memory map the data, and specify that we want to use this buffer\n// for vertex, index and uniform buffer storage\ncubePool, _ := c.app.ResourceManager.AllocateBufferPoolWithOptions(\"cube\", uint64(bytesNeeded),\n\tvk.MemoryPropertyHostCoherentBit|vk.MemoryPropertyHostVisibleBit,\n\tvk.BufferUsageVertexBufferBit|vk.BufferUsageIndexBufferBit|vk.BufferUsageUniformBufferBit,\n\tvk.SharingModeExclusive)\n\nm.VertexResource, _ = cubePool.AllocateBuffer(uint64(len(m.VertexData.Bytes())), vk.BufferUsageVertexBufferBit)\n\nm.IndexResource, _ = cubePool.AllocateBuffer(uint64(len(m.IndexData.Bytes())), vk.BufferUsageIndexBufferBit)\n\nm.UBOResource, _ = cubePool.AllocateBuffer(uint64(len(m.UBO.Bytes())), vk.BufferUsageUniformBufferBit)\n```\n\nHow to map memory:\n\n```go\n// Map the data so we can simply write to it\ncubePool.Memory.Map()\n\ncopy(m.VertexResource.Bytes(), m.VertexData.Bytes())\ncopy(m.IndexResource.Bytes(), m.IndexData.Bytes())\n\n```\n\nHow to configure a custom graphics pipeline\n```go\n// create a graphics pipeline\ngc := c.app.CreateGraphicsPipelineConfig()\n\n// our mesh implements in interface which allows it\n// to describe how it's vertex data is layed out, so we provide\n// that interface to our graphics pipeline\ngc.AddVertexDescriptor(c.mesh.VertexData)\n\n// load some shaders\ngc.AddShaderStageFromFile(\"shaders/vert.spv\", \"main\", vk.ShaderStageVertexBit)\ngc.AddShaderStageFromFile(\"shaders/frag.spv\", \"main\", vk.ShaderStageFragmentBit)\n\n// set our pipeline layout which describes how we wish to layout our data in our descriptors\ngc.SetPipelineLayout(c.pipelineLayout)\n\n// lastly we tell our graphics app about this pipeline config\n// we use named pipeline configs because at it's descretion the graphics app\n// must be able to recreate the actual pipelines from it's configs\nc.app.AddGraphicsPipelineConfig(\"cube\", gc)\n```\n\nHow to send commands to the graphics queue\n\n```go\n// because command buffers are allocated from a pool\n// and reused we must reset it\nbuffer.Reset()\n\n// clear values are used to clear the screen and depth buffer\nclearValues := make([]vk.ClearValue, 2)\nclearValues[0].SetColor([]float32{0.2, 0.2, 0.2, 1})\nclearValues[1].SetDepthStencil(1, 0)\n\n// begin recording commands\nbuffer.Begin()\n\n// create a render pass struct\nrenderPassBeginInfo := vk.RenderPassBeginInfo{\n\tSType:       vk.StructureTypeRenderPassBeginInfo,\n\tRenderPass:  c.app.VKRenderPass,\n\tFramebuffer: c.app.Framebuffers[frame],\n\tRenderArea: vk.Rect2D{\n\t\tOffset: vk.Offset2D{\n\t\t\tX: 0, Y: 0,\n\t\t},\n\t\tExtent: c.app.GetScreenExtent(),\n\t},\n\tClearValueCount: 2,\n\tPClearValues:    clearValues,\n}\n\nvk.CmdBeginRenderPass(buffer.VK(), \u0026renderPassBeginInfo, vk.SubpassContentsInline)\n\n// we tell vulkan which graphics pipeline we want to use - the one we defined above\nvk.CmdBindPipeline(buffer.VK(), vk.PipelineBindPointGraphics, c.app.GraphicsPipelines[\"cube\"])\n\n// tell it which buffer our vertex data comes from\nvk.CmdBindVertexBuffers(buffer.VK(), 0, 1, []vk.Buffer{c.mesh.VertexResource.VKBuffer}, []vk.DeviceSize{0})\n\n// tell it which buffer our index data comes from\nvk.CmdBindIndexBuffer(buffer.VK(), c.mesh.IndexResource.VKBuffer, vk.DeviceSize(0), vk.IndexTypeUint16)\n\n// tell vulkan about our descriptor sets which feed data to our shaders\nvk.CmdBindDescriptorSets(buffer.VK(), vk.PipelineBindPointGraphics,\n\tc.pipelineLayout.VKPipelineLayout, 0, 1,\n\t[]vk.DescriptorSet{c.mesh.descriptorSet.VKDescriptorSet}, 0, nil)\n\n// lastly tell vulkan which indexes to draw\nvk.CmdDrawIndexed(buffer.VK(), uint32(len(c.mesh.IndexData)), 1, 0, 0, 0)\n\nvk.CmdEndRenderPass(buffer.VK())\n\nbuffer.End()\n```\n\n\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fceler%2Fvkg","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fceler%2Fvkg","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fceler%2Fvkg/lists"}