Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up

Vulkan API higher-level framework and utils for Go programming language

License

NotificationsYou must be signed in to change notification settings

vulkan-go/asche

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

13 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

...because when you throw a gopher into volcano you get a pile of ash.

Asche is a high-level framework created to simplify development of Vulkan API applications using Go programming language. It manages Vulkan platform state and initialization, also provides an interface the app must conform in order to tell about desired platform requirements.

Currently it's used inVulkanCube demo app, please reference to it as an official Asche reference for now.

You should start by implementing this platform-describing interface:

typeApplicationinterface {VulkanInit(ctxContext)errorVulkanAPIVersion() vk.VersionVulkanAppVersion() vk.VersionVulkanAppName()stringVulkanMode()VulkanModeVulkanSurface(instance vk.Instance) vk.SurfaceVulkanInstanceExtensions() []stringVulkanDeviceExtensions() []stringVulkanDebug()bool// DECORATORS:// ApplicationSwapchainDimensions// ApplicationVulkanLayers// ApplicationContextPrepare// ApplicationContextCleanup// ApplicationContextInvalidate}

Usually the cross-platform code may inherit (by embedding) the default appas.BaseVulkanApp, and later you wrap your cross-platform code into platform-specific (as shown in Android and Desktop demos of cube) overriding method implementations for that interface.VulkanInit() may stay here from default app, as it doesn't do anything other than storing context state.ApplicationContextPrepare() can be overriden in cross-platform code as it must implement the application-specific logic. And finally the platform code overridesVulkanSurface() as it should acquire a validvk.Instance usingplatform-specificvk.CreateWindowSurface.

Decorators are considered to be optional methods that will be checked in runtime, with no default implementation, must be provided when needed by the app logic.

After platform intialization usingas.NewPlatform, the application has access to this Vulkan Platform Interface:

typePlatforminterface {// MemoryProperties gets the current Vulkan physical device memory properties.MemoryProperties() vk.PhysicalDeviceMemoryProperties// PhysicalDeviceProperies gets the current Vulkan physical device properties.PhysicalDeviceProperies() vk.PhysicalDeviceProperties// GraphicsQueueFamilyIndex gets the current Vulkan graphics queue family index.GraphicsQueueFamilyIndex()uint32// PresentQueueFamilyIndex gets the current Vulkan present queue family index.PresentQueueFamilyIndex()uint32// HasSeparatePresentQueue is true when PresentQueueFamilyIndex differs from GraphicsQueueFamilyIndex.HasSeparatePresentQueue()bool// GraphicsQueue gets the current Vulkan graphics queue.GraphicsQueue() vk.Queue// PresentQueue gets the current Vulkan present queue.PresentQueue() vk.Queue// Instance gets the current Vulkan instance.Instance() vk.Instance// Device gets the current Vulkan device.Device() vk.Device// PhysicalDevice gets the current Vulkan physical device.PhysicalDevice() vk.PhysicalDevice// Surface gets the current Vulkan surface.Surface() vk.Surface// Destroy is the destructor for the Platform instance.Destroy()}

And of course the Vulkan Context that can should be used in the app's logic and rendering loop:

typeContextinterface {// SetOnPrepare sets callback that will be invoked to initialize and prepare application's vulkan state// upon context prepare step. onCreate could create textures and pipelines,// descriptor layouts and render passes.SetOnPrepare(onPreparefunc()error)// SetOnCleanup sets callback that will be invoked to cleanup application's vulkan state// upon context prepare step. onCreate could destroy textures and pipelines,// descriptor layouts and render passes.SetOnCleanup(onCleanupfunc()error)// SetOnInvalidate sets callback that will be invoked when context has been invalidated,// the application must update its state and prepare the corresponding swapchain image to be presented.// onInvalidate could compute new vertex and color data in swapchain image resource buffers.SetOnInvalidate(onInvalidatefunc(imageIdxint)error)// Device gets the Vulkan device assigned to the context.Device() vk.Device// Platform gets the current platform.Platform()Platform// CommandBuffer gets a command buffer currently active.CommandBuffer() vk.CommandBuffer// SwapchainDimensions gets the current swapchain dimensions, including pixel format.SwapchainDimensions()*SwapchainDimensions// SwapchainImageResources exposes the swapchain initialized image resources.SwapchainImageResources() []*SwapchainImageResources// AcquireNextImageAcquireNextImage() (imageIndexint,outdatedbool,errerror)// PresentImagePresentImage(imageIdxint) (outdatedbool,errerror)}

BothVulkan Platform Interface andVulkan Context terms are made up just for clarity, please note that Vulkan API has a little to none amount of abstraction, so Asche provides this state management tools to free the developer from extra burden. However, it's too easy to create leaky abstractions for Vulkan API, so Asche tries to be as minimal and pragmatic as possible.

License

MIT

About

Vulkan API higher-level framework and utils for Go programming language

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages


[8]ページ先頭

©2009-2025 Movatter.jp