Documentation ¶
Overview ¶
Package vkg implements an abstraction atop the Vulkan graphics framework for go. Vulkan is a very powerful graphics and compute framework, which expands upon what is possible with OpenGL and OpenCL, but at a cost - it is very difficult and complex to use, yet very powerful.
This package provides utility functions and objects which make Vulkan a little more paltable to gophers, with the drawback that it cannot possibly expose all the power inherent in Vulkan, so it strives to avoid limiting users when they desire to utilize the full power of Vulkan.
Overview of Vulkan ¶
Vulkan overcomes many of the drawbacks of OpenGL by providing a much less abstracted interface to GPUs at a pretty hefty cost, all the things OpenGL managed previously are now up to the implementing application to manage. This documentation is woefully inadequate at fully descrbing how Vulkan works, and is meant to provide a refersher and perhaps some bread crumbs which will aid in undersatnding the system.
At a high level vulkan provides a method of submiting work to command queues which execute various pipeline (which the application has configured) to either display graphics or peform compute work. An example of a pipeline might be one which displays a set of vertex data in a specific way, or a compute pipeline which pefroms some massively parallel mathmatical operation on a large set of data. The challenge then becomes providing the data in a way which these pipelines can utilize, so the data must be described adqueately enough so that the GPU can work with the data in an optimal way. To allow application developers to better utilize the underlying hardware, many decisions about how this data is managed is now left up to the application developer, rather than manged by a framework like OpenGL.
This means the application developer is now responsible for deciding where the data which is to be processed by the pipeline will reside, what the format of the data is and how to make sure the data arrives at the appopriate time to best utilize the underlying hardware (this is a daunting task and application specific). So a game developed with Vulkan will have different needs and priorites than a scientific computing application developed with Vulkan, or even a 3D editor.
This package can provide some assitance in getting started with vulkan but cannot possibly provide apporpaite abstractions for all possible use cases, or else it would fall into the trap of OpenGL - doing too much in a sub optimal way.
Back to a discussion of Vulkan, we have command queues, which are feeding pipelines, which are using data provided by the application.
Native Vulkan terms
Instance the vulkan runtime instance PhysicalDevice the physical hardware device LogicalDevice a representation of the device which is the target of most of the vulkan apis. Pipeline a description of how to process data on the GPU Queue a queue which work (comand buffers) may be submitted to DeviceMemory a allocation of memory on the host or device for use by buffers and images Buffer a description of some bit of data (vertex, index, or other) Image a description of some image ImageView a way of descibing how an image is utilized or viewed DescriptorSet a mapping of data for use by shaders DescriptorSetLayout a description of what data is in the descriptor set Swapchain a grouping of images which are used to display graphical data
When thinking about how a graphics application with Vulkan works a very high level sequences of might be:
- Intialize the vulkan instance
- Setup the swapchain and framebuffers
- Allocate buffers and device memory 3a. Allocate a buffer and memory on the host for vertex data 3b. Allocate a staging buffer in host memory to send texture data to the device 3c. Allocate a image in the device memory to recieve the texture data
- Load data 4a. Load vertex into the host allocated memory by 'mapping' the memory 4b. Load texture data into a host allocated staging buffer
- Query the physical device for queues which work may be submitted to
- Submit a command buffer to a device queue to copy the image data loaded in 3b. to the image created in 3c
- Create a descriptor set which describes how data is related in the application
- Configure and create a graphics pipeline (and provide it the descriptor set)
- Start drawing frames:
- Fill a command buffer with the pipeline and vertex details to draw
- Draw the image and display it.
About this package ¶
This package provides a basic set of APIs which wrap some of the Vulkan APIs to make them a bit less painful to work with, the trade off being that many of the native Vulkan APIs expose options which are not exposed in the APIs provided by the package. To mitigate the drawback of this approach native vulkan structures are exposed in all the objects prefixed with the 'VK' in the name - so applications aren't limited by what this package provides.
This package goes beyond what Vulkan natively provides to make Vulkan a bit easier to work with:
GraphicsApp:
a basic graphics application framework which managed setup and frame drawing
ResourceManager:
a resource manager which manages memory allocation and can assist with staging of resources
Utility interfaces:
for using and describing data
Index ¶
- Constants
- Variables
- func DefaultDebugCallback(flags vk.DebugReportFlags, objectType vk.DebugReportObjectType, object uint64, ...) vk.Bool32
- func InitializeForComputeOnly() error
- func SupportedExtensions() ([]string, error)
- func SupportedLayers() ([]string, error)
- func ToBytes(ptr unsafe.Pointer, lenInBytes int) []byte
- type Allocation
- type App
- type Buffer
- type BufferResource
- func (r *BufferResource) AllocateStagingResource() error
- func (r *BufferResource) Bytes() []byte
- func (r *BufferResource) Destroy()
- func (r *BufferResource) Free()
- func (r *BufferResource) FreeStagingResource()
- func (r *BufferResource) RequiresStaging() bool
- func (r *BufferResource) String() string
- func (r *BufferResource) VKMappedMemoryRange() vk.MappedMemoryRange
- type BufferResourcePool
- type ByteSourcer
- type CommandBuffer
- func (c *CommandBuffer) Begin() error
- func (c *CommandBuffer) BeginContinueRenderPass(renderpass vk.RenderPass, framebuffer vk.Framebuffer) error
- func (c *CommandBuffer) BeginOneTime() error
- func (c *CommandBuffer) CmdBindComputePipeline(p *ComputePipeline)
- func (c *CommandBuffer) CmdBindDescriptorSets(bindPoint vk.PipelineBindPoint, layout *PipelineLayout, firstSet int, ...)
- func (c *CommandBuffer) CmdCopyBufferFromStagedResource(resource *BufferResource)
- func (c *CommandBuffer) CmdDispatch(x, y, z int)
- func (c *CommandBuffer) End() error
- func (c *CommandBuffer) Reset() error
- func (c *CommandBuffer) ResetAndRelease() error
- func (cb *CommandBuffer) StageImageResource(img *ImageResource) error
- func (cb *CommandBuffer) TransitionImageLayout(img *ImageResource, format vk.Format, oldLayout, newLayout vk.ImageLayout)
- func (c *CommandBuffer) VK() vk.CommandBuffer
- type CommandPool
- func (c *CommandPool) AllocateBuffer(level vk.CommandBufferLevel) (*CommandBuffer, error)
- func (c *CommandPool) AllocateBuffers(count int, level vk.CommandBufferLevel) ([]*CommandBuffer, error)
- func (c *CommandPool) Destroy()
- func (c *CommandPool) FreeBuffer(b *CommandBuffer)
- func (c *CommandPool) FreeBuffers(bs []*CommandBuffer)
- type ComputePipeline
- type CreateDeviceOptions
- type CreateSwapchainOptions
- type DebugCallback
- type Descriptor
- type DescriptorBinder
- type DescriptorPool
- type DescriptorSet
- type DescriptorSetLayout
- type Device
- func (d *Device) Allocate(sizeInBytes int, memoryTypeBits uint32, ...) (*DeviceMemory, error)
- func (d *Device) CreateBufferWithOptions(sizeInBytes uint64, usage vk.BufferUsageFlagBits, sharing vk.SharingMode) (*Buffer, error)
- func (d *Device) CreateCommandPool(q *QueueFamily) (*CommandPool, error)
- func (d *Device) CreateComputePipelines(pc *PipelineCache, cp ...*ComputePipeline) error
- func (d *Device) CreateDescriptorPool(pool *DescriptorPool, maxSets int) (*DescriptorPool, error)
- func (d *Device) CreateDescriptorSetLayout(layout *DescriptorSetLayout) (*DescriptorSetLayout, error)
- func (d *Device) CreateFence() (*Fence, error)
- func (d *Device) CreateGraphicsPipelineConfig() *GraphicsPipelineConfig
- func (d *Device) CreateImageWithOptions(extent vk.Extent2D, format vk.Format, tiling vk.ImageTiling, ...) (*Image, error)
- func (d *Device) CreatePipelineCache() (*PipelineCache, error)
- func (d *Device) CreatePipelineLayout(descriptorSetLayouts ...*DescriptorSetLayout) (*PipelineLayout, error)
- func (d *Device) CreatePipelineLayoutWithPushConstants(descriptorSetLayouts []*DescriptorSetLayout, ...) (*PipelineLayout, error)
- func (d *Device) CreateResourceManager() *ResourceManager
- func (p *Device) CreateSwapchain(surface vk.Surface, graphicsQueue, presentQueue *Queue, ...) (*Swapchain, error)
- func (p *Device) DefaultNumSwapchainImages(surface vk.Surface) (int, error)
- func (d *Device) Destroy()
- func (d *Device) DestroyAny(i interface{})
- func (d *Device) FlushMappedRanges(r ...MappedMemoryRange) error
- func (d *Device) GetQueue(qf *QueueFamily) *Queue
- func (d *Device) LoadShaderModuleFromFile(file string) (*ShaderModule, error)
- func (d *Device) NewDescriptorPool() *DescriptorPool
- func (d *Device) NewDescriptorSet() *DescriptorSet
- func (d *Device) NewDescriptorSetLayout() *DescriptorSetLayout
- func (d *Device) String() string
- func (d *Device) VKCreateFence(signaled bool) (vk.Fence, error)
- func (d *Device) VKCreateSemaphore() (vk.Semaphore, error)
- func (d *Device) VKDestroyFence(f vk.Fence)
- func (d *Device) VKDestroySemaphore(s vk.Semaphore)
- func (d *Device) VKGetFenceStatus(f vk.Fence) vk.Result
- func (d *Device) WaitForFences(waitForAll bool, ts time.Duration, fences ...*Fence) error
- func (d *Device) WaitIdle() error
- type DeviceMemory
- func (d *DeviceMemory) Destroy()
- func (d *DeviceMemory) IsMapped() bool
- func (d *DeviceMemory) Map() (unsafe.Pointer, error)
- func (d *DeviceMemory) MapCopyUnmap(data []byte) error
- func (d *DeviceMemory) MapWithOffset(size uint64, offset uint64) (unsafe.Pointer, error)
- func (d *DeviceMemory) MapWithSize(size int) (unsafe.Pointer, error)
- func (d *DeviceMemory) Unmap()
- type Fence
- type GraphicsApp
- func (p *GraphicsApp) AddGraphicsPipelineConfig(name string, config IGraphicsPipelineConfig)
- func (p *GraphicsApp) CreateGraphicsPipelineConfig() *GraphicsPipelineConfig
- func (p *GraphicsApp) Destroy()
- func (p *GraphicsApp) DrawFrameSync() error
- func (p *GraphicsApp) EnableDebugging() bool
- func (p *GraphicsApp) EnableExtension(extension string) bool
- func (p *GraphicsApp) EnableLayer(layer string) bool
- func (p *GraphicsApp) GetScreenExtent() vk.Extent2D
- func (p *GraphicsApp) Init() error
- func (p *GraphicsApp) NumFramebuffers() int
- func (p *GraphicsApp) PhysicalDevices() ([]*PhysicalDevice, error)
- func (p *GraphicsApp) PrepareToDraw() error
- func (p *GraphicsApp) Resize()
- func (p *GraphicsApp) SetWindow(window *glfw.Window) error
- func (p *GraphicsApp) SupportedExtensions() ([]string, error)
- func (p *GraphicsApp) SupportedLayers() ([]string, error)
- func (p *GraphicsApp) VKRenderPassCreateInfo() vk.RenderPassCreateInfo
- type GraphicsPipelineConfig
- func (g *GraphicsPipelineConfig) AddBlendAttachment(ba vk.PipelineColorBlendAttachmentState)
- func (g *GraphicsPipelineConfig) AddDescriptorSetLayout(d *DescriptorSetLayout) *GraphicsPipelineConfig
- func (g *GraphicsPipelineConfig) AddShaderStageFromFile(file, entryPoint string, stageType vk.ShaderStageFlagBits) error
- func (g *GraphicsPipelineConfig) AddVertexDescriptor(v VertexDescriptor) *GraphicsPipelineConfig
- func (g *GraphicsPipelineConfig) Destroy()
- func (g *GraphicsPipelineConfig) SetCullMode(mode vk.CullModeFlagBits) *GraphicsPipelineConfig
- func (g *GraphicsPipelineConfig) SetDynamicState(states ...vk.DynamicState) *GraphicsPipelineConfig
- func (g *GraphicsPipelineConfig) SetPipelineLayout(layout *PipelineLayout) *GraphicsPipelineConfig
- func (g *GraphicsPipelineConfig) SetShaderStages(shaderStages []vk.PipelineShaderStageCreateInfo) *GraphicsPipelineConfig
- func (g *GraphicsPipelineConfig) VKGraphicsPipelineCreateInfo(extent vk.Extent2D) (vk.GraphicsPipelineCreateInfo, error)
- type IAllocatedItem
- type IAllocator
- type IDestructable
- type IGraphicsPipelineConfig
- type Image
- type ImageResource
- func (r *ImageResource) AllocateStagingResource() error
- func (r *ImageResource) Bytes() ([]byte, error)
- func (r *ImageResource) Destroy()
- func (r *ImageResource) Free()
- func (r *ImageResource) FreeStagingResource()
- func (r *ImageResource) RequiresStaging() bool
- func (r *ImageResource) String() string
- type ImageResourcePool
- func (p *ImageResourcePool) AllocateImage(extent vk.Extent2D, format vk.Format, tiling vk.ImageTiling, ...) (*ImageResource, error)
- func (p *ImageResourcePool) Destroy()
- func (p *ImageResourcePool) LogDetails()
- func (p *ImageResourcePool) StageTextureFromDisk(filename string, cmd *CommandBuffer, queue *Queue) (*ImageResource, error)
- func (p *ImageResourcePool) StageTextureFromImage(srcImg *image.RGBA, cmd *CommandBuffer, queue *Queue) (*ImageResource, error)
- type ImageView
- type IndexSliceUint16
- type IndexSliceUint32
- type IndexSourcer
- type Instance
- type LinearAllocator
- type MappedMemoryRange
- type MemoryTypeSlice
- type PhysicalDevice
- func (p *PhysicalDevice) CreateLogicalDevice(qfs QueueFamilySlice) (*Device, error)
- func (p *PhysicalDevice) CreateLogicalDeviceWithOptions(qfs QueueFamilySlice, options *CreateDeviceOptions) (*Device, error)
- func (p *PhysicalDevice) FindMemoryType(memoryTypeBits uint32, properties vk.MemoryPropertyFlagBits) (uint32, error)
- func (p *PhysicalDevice) GetSurfaceCapabilities(surface vk.Surface) (*vk.SurfaceCapabilities, error)
- func (p *PhysicalDevice) GetSurfaceFormats(surface vk.Surface) (VKSurfaceFormats, error)
- func (p *PhysicalDevice) GetSurfacePresentModes(surface vk.Surface) (VKPresentModes, error)
- func (p *PhysicalDevice) MemoryTypes() []vk.MemoryType
- func (p *PhysicalDevice) QueueFamilies() (QueueFamilySlice, error)
- func (p *PhysicalDevice) String() string
- func (p *PhysicalDevice) SupportedExtensions() ([]vk.ExtensionProperties, error)
- func (p *PhysicalDevice) VKPhysicalDeviceFeatures() vk.PhysicalDeviceFeatures
- func (p *PhysicalDevice) VKPhysicalDeviceMemoryProperties() vk.PhysicalDeviceMemoryProperties
- type PipelineCache
- type PipelineLayout
- type Queue
- type QueueFamily
- type QueueFamilySlice
- func (ql QueueFamilySlice) Filter(f func(q *QueueFamily) bool) QueueFamilySlice
- func (ql QueueFamilySlice) FilterCompute() QueueFamilySlice
- func (ql QueueFamilySlice) FilterGraphics() QueueFamilySlice
- func (ql QueueFamilySlice) FilterGraphicsAndPresent(surface vk.Surface) QueueFamilySlice
- func (ql QueueFamilySlice) FilterPresent(surface vk.Surface) QueueFamilySlice
- func (ql QueueFamilySlice) FilterTransfer() QueueFamilySlice
- type ResourceManager
- func (r *ResourceManager) AllocateBufferPoolWithOptions(name string, size uint64, mprops vk.MemoryPropertyFlagBits, ...) (*BufferResourcePool, error)
- func (r *ResourceManager) AllocateDeviceTexturePool(name string, size uint64) (*ImageResourcePool, error)
- func (r *ResourceManager) AllocateHostVertexAndIndexBufferPool(name string, size uint64) (*BufferResourcePool, error)
- func (r *ResourceManager) AllocateImagePoolWithOptions(name string, size uint64, mprops vk.MemoryPropertyFlagBits, ...) (*ImageResourcePool, error)
- func (r *ResourceManager) AllocateStagingPool(size uint64) (*BufferResourcePool, error)
- func (r *ResourceManager) BufferPool(name string) *BufferResourcePool
- func (r *ResourceManager) Destroy()
- func (r *ResourceManager) GetStagingPool() *BufferResourcePool
- func (r *ResourceManager) HasStagingPool() bool
- func (r *ResourceManager) ImagePool(name string) *ImageResourcePool
- func (r *ResourceManager) LogDetails()
- func (r *ResourceManager) NewImageResourceWithOptions(extent vk.Extent2D, format vk.Format, tiling vk.ImageTiling, ...) (*ImageResource, error)
- type ShaderModule
- type Swapchain
- type UpdateFrequencyType
- type VKBufferProvider
- type VKImageProvider
- type VKPresentModes
- type VKSurfaceFormats
- type Version
- type VertexDescriptor
- type VertexSourcer
Constants ¶
const StagingPoolName = "staging"
const StopCmdBufferConstruction = -1
StopCmdBufferConstruction is used to signal that command buffer construction should stop
Variables ¶
var FrameLag = 3
Functions ¶
func DefaultDebugCallback ¶
func DefaultDebugCallback(flags vk.DebugReportFlags, objectType vk.DebugReportObjectType, object uint64, location uint, messageCode int32, pLayerPrefix string, pMessage string, pUserData unsafe.Pointer) vk.Bool32
DefaultDebugCallback - taken from github.com/vulkan-go/asche/
func InitializeForComputeOnly ¶
func InitializeForComputeOnly() error
InitializeCompute initializes Vulkan for a compute based task, it doesn't enable any graphics capabilties.
func SupportedExtensions ¶
SupportedExtensions returns a list of supported extensions for use by Vulkan this may crash if Vulkan has not been initialized previously for use in a compute, or graphics capability of some kind
func SupportedLayers ¶
SupportedLayers returns a list of supported layers for use by Vulkan this may crash if Vulkan has not been initialized previously for use in a compute, or graphics capability of some kind
Types ¶
type Allocation ¶
type Allocation struct { // Offset in memory to this object Offset uint64 // Size of the allocated memory Size uint64 // The item that was allocated Object IAllocatedItem }
Allocation is an allocation of some hunk of memory
type App ¶
type App struct { // Name the name of the application Name string // Engine the name of the engine associated with the application EngineName string // Version the version of the application Version Version // APIVersion the expected minimum version of the Vulkan API (i.e. 1.0.0) APIVersion Version // EnabledLayers the enabled layers EnabledLayers []string // EnabledExtensions the enabled extensions EnabledExtensions []string }
App is used to provide information about this specific application to Vulkan
func (*App) CreateInstance ¶
CreateInstance creates an the Vulkan Instance
func (*App) EnableDebugging ¶
func (a *App) EnableDebugging()
func (*App) EnableExtension ¶
Enable an extension for use by the application
func (*App) EnableLayer ¶
Enable a specific layer
func (*App) VKApplicationInfo ¶
func (a *App) VKApplicationInfo() vk.ApplicationInfo
VKApplicationInfo creates a structure representing this application in a Vulkan friendly format
type Buffer ¶
Buffer in vulkan are essentially a way of identifying and describing resources to the system. So for example you can have a buffer which holds vertex data in a specific format, or index data or a U.B.O (Uniform Buffer Object - which is data which is provided to a shader), or a buffer which is a source or destination for data from other locations. Buffers can reside either in the host memory or in the GPU (device) memory. The buffer itself is not the allocation of memory but simply a description of what the memory is and where it is. Device or host memory must still be allocated using the physical device object to actually hold the data associated with the buffer.
func (*Buffer) Bind ¶
func (b *Buffer) Bind(memory *DeviceMemory, offset uint64) error
Bind associates a specific bit of device memory with this buffer, essentially identifying the memory as being used by this buffer. The offset is provied so that the buffer can be bound to a certain place in memory. There is a requirement that the buffer be bound in accordance with the alignment requirements returned by .VKMemoryRequirements().
func (*Buffer) VKMemoryRequirements ¶
func (b *Buffer) VKMemoryRequirements() vk.MemoryRequirements
VKMemoryRequirements returns the vulkan native vk.MemoryRequirements objects which can be inspected to learn more about the memory requirements assocaited with this buffer. (You must call .Deref() on this object to populate it).
type BufferResource ¶
type BufferResource struct { Buffer ResourcePool *BufferResourcePool Allocation *Allocation StagingResource *BufferResource }
BufferResource is a buffer based resource, for example vertex buffer, index buffer, UBO, which have been allocated from a larger pool of device memory. Vulkan limits the number of memory allocations that can be done by an application, so applications should manage their own pools of memory. A BufferResource is a buffer which has been managed by the ResourceManager.
func (*BufferResource) AllocateStagingResource ¶
func (r *BufferResource) AllocateStagingResource() error
AllocateStagingResource will allocate an apporpriate resource which can be used for staging this resource. Once allocated it must be explicitly free'd. The staging resource is allocated from a resource pool called 'staging', which the program must create
func (*BufferResource) Bytes ¶
func (r *BufferResource) Bytes() []byte
Bytes returns a byte slice representing the mapped memory, which can be read from or copied to
func (*BufferResource) Destroy ¶
func (r *BufferResource) Destroy()
func (*BufferResource) Free ¶
func (r *BufferResource) Free()
Free this resource and it's associated resources
func (*BufferResource) FreeStagingResource ¶
func (r *BufferResource) FreeStagingResource()
FreeStagingResource will free the staged resource associated with this resource
func (*BufferResource) RequiresStaging ¶
func (r *BufferResource) RequiresStaging() bool
RequiresStaging indicates that this particular buffer resource must be staged before it can be used. This is primarly indicative that the BufferResource is stored in device memory.
func (*BufferResource) String ¶
func (r *BufferResource) String() string
func (*BufferResource) VKMappedMemoryRange ¶
func (r *BufferResource) VKMappedMemoryRange() vk.MappedMemoryRange
VKMappedMemoryRange is provided so that the buffer implements MappedMemoryRange interface which can be used by device.FlushMappedRanges(...)
type BufferResourcePool ¶
type BufferResourcePool struct { Device *Device Name string Usage vk.BufferUsageFlagBits Sharing vk.SharingMode MemoryProperties vk.MemoryPropertyFlagBits Size uint64 Allocator IAllocator Memory *DeviceMemory NeedsStaging bool ResourceManager *ResourceManager }
func (*BufferResourcePool) AllocateBuffer ¶
func (p *BufferResourcePool) AllocateBuffer(size uint64, usage vk.BufferUsageFlagBits) (*BufferResource, error)
func (*BufferResourcePool) AllocateFor ¶
func (p *BufferResourcePool) AllocateFor(src ByteSourcer) (*BufferResource, error)
func (*BufferResourcePool) Destroy ¶
func (p *BufferResourcePool) Destroy()
func (*BufferResourcePool) LogDetails ¶
func (p *BufferResourcePool) LogDetails()
type ByteSourcer ¶
type ByteSourcer interface {
Bytes() []byte
}
You try to make a idiomatic go interface name out of an object that can represent stuff as bytes - byteabler?
type CommandBuffer ¶
type CommandBuffer struct {
VKCommandBuffer vk.CommandBuffer
}
CommandBuffers describe a sequence of commands that will be executed upon being sent to a device queue. Not all available vulkan commands are wrapped by this package. It is expected that the calling application must call the native vulkan command APIs.
func (*CommandBuffer) Begin ¶
func (c *CommandBuffer) Begin() error
Begin capturing work for this command buffer
func (*CommandBuffer) BeginContinueRenderPass ¶
func (c *CommandBuffer) BeginContinueRenderPass(renderpass vk.RenderPass, framebuffer vk.Framebuffer) error
Begin capturing work for this command buffer
func (*CommandBuffer) BeginOneTime ¶
func (c *CommandBuffer) BeginOneTime() error
BeginOneTime begins capturing work for this command buffer, with the stipulation that it will only be used once (instead of put back in the pool of command buffers)
func (*CommandBuffer) CmdBindComputePipeline ¶
func (c *CommandBuffer) CmdBindComputePipeline(p *ComputePipeline)
func (*CommandBuffer) CmdBindDescriptorSets ¶
func (c *CommandBuffer) CmdBindDescriptorSets(bindPoint vk.PipelineBindPoint, layout *PipelineLayout, firstSet int, descriptorSets ...*DescriptorSet)
func (*CommandBuffer) CmdCopyBufferFromStagedResource ¶
func (c *CommandBuffer) CmdCopyBufferFromStagedResource(resource *BufferResource)
CmdCopyBufferFromStagedResource will populate this buffer from the previously allocated staged resource
func (*CommandBuffer) CmdDispatch ¶
func (c *CommandBuffer) CmdDispatch(x, y, z int)
func (*CommandBuffer) End ¶
func (c *CommandBuffer) End() error
End describing work for this command buffer
func (*CommandBuffer) ResetAndRelease ¶
func (c *CommandBuffer) ResetAndRelease() error
ResetAndRelease will reset this commandbuffer and release the associated resources
func (*CommandBuffer) StageImageResource ¶
func (cb *CommandBuffer) StageImageResource(img *ImageResource) error
func (*CommandBuffer) TransitionImageLayout ¶
func (cb *CommandBuffer) TransitionImageLayout(img *ImageResource, format vk.Format, oldLayout, newLayout vk.ImageLayout)
func (*CommandBuffer) VK ¶
func (c *CommandBuffer) VK() vk.CommandBuffer
VK is a utility function for accessing the native vulkan command buffer
type CommandPool ¶
type CommandPool struct { Device *Device QueueFamily *QueueFamily VKCommandPool vk.CommandPool }
CommandPool for managing a pool of command buffers
func (*CommandPool) AllocateBuffer ¶
func (c *CommandPool) AllocateBuffer(level vk.CommandBufferLevel) (*CommandBuffer, error)
AllocateBuffer allocates a single command buffer
func (*CommandPool) AllocateBuffers ¶
func (c *CommandPool) AllocateBuffers(count int, level vk.CommandBufferLevel) ([]*CommandBuffer, error)
AllocateBuffers allocates some number of command buffers
func (*CommandPool) FreeBuffer ¶
func (c *CommandPool) FreeBuffer(b *CommandBuffer)
FreeBuffer frees a single buffer
func (*CommandPool) FreeBuffers ¶
func (c *CommandPool) FreeBuffers(bs []*CommandBuffer)
FreeBuffers frees a set of command buffers
type ComputePipeline ¶
type ComputePipeline struct { Device *Device VKPipeline vk.Pipeline VKPipelineShaderStageCreateInfo vk.PipelineShaderStageCreateInfo VKPipelineLayout vk.PipelineLayout }
func (*ComputePipeline) Destroy ¶
func (c *ComputePipeline) Destroy()
func (*ComputePipeline) SetPipelineLayout ¶
func (c *ComputePipeline) SetPipelineLayout(layout *PipelineLayout)
func (*ComputePipeline) SetShaderStage ¶
func (c *ComputePipeline) SetShaderStage(entryPoint string, shaderModule *ShaderModule)
type CreateDeviceOptions ¶
type CreateSwapchainOptions ¶
type DebugCallback ¶
type Descriptor ¶
type Descriptor struct { Type vk.DescriptorType ShaderStage vk.ShaderStageFlags Set int Binding int }
type DescriptorBinder ¶
type DescriptorBinder interface {
Descriptor() *Descriptor
}
type DescriptorPool ¶
type DescriptorPool struct { Device *Device VKDescriptorPool vk.DescriptorPool VKDescriptorPoolSize []vk.DescriptorPoolSize }
DescriptorPool is essentially a resource manager for descriptor pools provided by Vulkan.
func (*DescriptorPool) AddPoolSize ¶
func (d *DescriptorPool) AddPoolSize(dtype vk.DescriptorType, count int)
AddPoolSize informs the descriptor pool how many of a certain descriptortype it will contain
func (*DescriptorPool) Allocate ¶
func (d *DescriptorPool) Allocate(layouts ...*DescriptorSetLayout) (*DescriptorSet, error)
Allocate allocates a descriptor set from the pool given the descriptor set layout
func (*DescriptorPool) Destroy ¶
func (d *DescriptorPool) Destroy()
func (*DescriptorPool) Free ¶
func (d *DescriptorPool) Free(ds *DescriptorSet) error
func (*DescriptorPool) Reset ¶
func (d *DescriptorPool) Reset() error
type DescriptorSet ¶
type DescriptorSet struct { Device *Device DescriptorPool *DescriptorPool VKDescriptorSet vk.DescriptorSet VKWriteDiscriptorSet []vk.WriteDescriptorSet }
DescriptorSet is a binding of resources to a descriptor, per a specific DescriptorSetLayout
func (*DescriptorSet) AddBuffer ¶
func (du *DescriptorSet) AddBuffer(dstBinding int, dtype vk.DescriptorType, b *Buffer, offset int)
AddBuffer adds a specific buffer to this descirptor set
func (*DescriptorSet) AddCombinedImageSampler ¶
func (du *DescriptorSet) AddCombinedImageSampler(dstBinding int, layout vk.ImageLayout, imageView vk.ImageView, sampler vk.Sampler)
AddCombinedImageSampler adds an image layout, image view and sampler to support displaying a texture
type DescriptorSetLayout ¶
type DescriptorSetLayout struct { Device *Device VKDescriptorSetLayout vk.DescriptorSetLayout VKDescriptorSetLayoutBindings []vk.DescriptorSetLayoutBinding }
DescriptorSetLayout describes the layout of a descriptorset
func (*DescriptorSetLayout) AddBinding ¶
func (d *DescriptorSetLayout) AddBinding(binding vk.DescriptorSetLayoutBinding)
AddBinding adds a binding to the descriptor set
func (*DescriptorSetLayout) Destroy ¶
func (d *DescriptorSetLayout) Destroy()
Destroy destroys this descriptor set layout
type Device ¶
type Device struct { PhysicalDevice *PhysicalDevice VKDevice vk.Device }
Device is a logical device per Vulkan terminology
func (*Device) Allocate ¶
func (d *Device) Allocate(sizeInBytes int, memoryTypeBits uint32, memoryProperties vk.MemoryPropertyFlagBits) (*DeviceMemory, error)
Allocate allocates a certain amount and type of memory
func (*Device) CreateBufferWithOptions ¶
func (d *Device) CreateBufferWithOptions(sizeInBytes uint64, usage vk.BufferUsageFlagBits, sharing vk.SharingMode) (*Buffer, error)
CreateBufferWithOptions creates a buffer object of a certain size, for a certain usage, with certain sharing options. This buffer can be used to describe memory which is allocated on either the host or device.
func (*Device) CreateCommandPool ¶
func (d *Device) CreateCommandPool(q *QueueFamily) (*CommandPool, error)
CreateCommandPool given a specific queue family
func (*Device) CreateComputePipelines ¶
func (d *Device) CreateComputePipelines(pc *PipelineCache, cp ...*ComputePipeline) error
func (*Device) CreateDescriptorPool ¶
func (d *Device) CreateDescriptorPool(pool *DescriptorPool, maxSets int) (*DescriptorPool, error)
CreateDescriptorPool creates the descriptor pool
func (*Device) CreateDescriptorSetLayout ¶
func (d *Device) CreateDescriptorSetLayout(layout *DescriptorSetLayout) (*DescriptorSetLayout, error)
CreateDescriptorSetLayout creates this descriptor set layout
func (*Device) CreateFence ¶
func (*Device) CreateGraphicsPipelineConfig ¶
func (d *Device) CreateGraphicsPipelineConfig() *GraphicsPipelineConfig
CreateGraphicsPipelineConfig creates a new config object
func (*Device) CreateImageWithOptions ¶
func (d *Device) CreateImageWithOptions(extent vk.Extent2D, format vk.Format, tiling vk.ImageTiling, usage vk.ImageUsageFlagBits) (*Image, error)
CreateImageWithOptions creates an image with some commonly used options
func (*Device) CreatePipelineCache ¶
func (d *Device) CreatePipelineCache() (*PipelineCache, error)
func (*Device) CreatePipelineLayout ¶
func (d *Device) CreatePipelineLayout(descriptorSetLayouts ...*DescriptorSetLayout) (*PipelineLayout, error)
func (*Device) CreatePipelineLayoutWithPushConstants ¶
func (d *Device) CreatePipelineLayoutWithPushConstants(descriptorSetLayouts []*DescriptorSetLayout, pushConstants []vk.PushConstantRange) (*PipelineLayout, error)
func (*Device) CreateResourceManager ¶
func (d *Device) CreateResourceManager() *ResourceManager
func (*Device) CreateSwapchain ¶
func (*Device) DefaultNumSwapchainImages ¶
func (*Device) DestroyAny ¶
func (d *Device) DestroyAny(i interface{})
DestroyAny is a utility function which given an item will try to figure out how to destroy it
func (*Device) FlushMappedRanges ¶
func (d *Device) FlushMappedRanges(r ...MappedMemoryRange) error
FlushMappedRanges will flush mapped memory ranges, it can take a BufferResource directly, as it implements the required interface
func (*Device) GetQueue ¶
func (d *Device) GetQueue(qf *QueueFamily) *Queue
GetQueue gets a queue matching a specific queue family
func (*Device) LoadShaderModuleFromFile ¶
func (d *Device) LoadShaderModuleFromFile(file string) (*ShaderModule, error)
func (*Device) NewDescriptorPool ¶
func (d *Device) NewDescriptorPool() *DescriptorPool
func (*Device) NewDescriptorSet ¶
func (d *Device) NewDescriptorSet() *DescriptorSet
func (*Device) NewDescriptorSetLayout ¶
func (d *Device) NewDescriptorSetLayout() *DescriptorSetLayout
func (*Device) VKCreateSemaphore ¶
VKCreateSemaphore creates a native vulkan semaphore object
func (*Device) VKDestroyFence ¶
func (*Device) VKDestroySemaphore ¶
func (*Device) WaitForFences ¶
type DeviceMemory ¶
type DeviceMemory struct { Device *Device VKDeviceMemory vk.DeviceMemory Size uint64 MapCount int32 Ptr unsafe.Pointer }
DeviceMemory maps to Vulkan DeviceMemory and can either be memory on the host or on the device
func (*DeviceMemory) IsMapped ¶
func (d *DeviceMemory) IsMapped() bool
IsMapped returns true if the device memory is currently mapped
func (*DeviceMemory) Map ¶
func (d *DeviceMemory) Map() (unsafe.Pointer, error)
Map will map the entirety of this memory
func (*DeviceMemory) MapCopyUnmap ¶
func (d *DeviceMemory) MapCopyUnmap(data []byte) error
MapCopyUnmap will map this memory, copy the specified data to it and unmap
func (*DeviceMemory) MapWithOffset ¶
MapWithOffset will map the memory with a certain size and offset
func (*DeviceMemory) MapWithSize ¶
func (d *DeviceMemory) MapWithSize(size int) (unsafe.Pointer, error)
MapWithSize will map this memory starting at offset 0 with a particular size
type GraphicsApp ¶
type GraphicsApp struct { Instance *Instance App *App Window *glfw.Window VKSurface vk.Surface Device *Device PhysicalDevice *PhysicalDevice CommandBuffers []*CommandBuffer GraphicsPipelineConfigs map[string]IGraphicsPipelineConfig // Generated from GraphicsPipelineConfigs GraphicsPipelines map[string]vk.Pipeline ResourceManager *ResourceManager GraphicsQueue *Queue PresentQueue *Queue PipelineCache *PipelineCache GraphicsCommandPool *CommandPool GraphicsCommandBuffers []*CommandBuffer DefaultNumSwapchainImages int Swapchain *Swapchain SwapchainImages []*Image SwapchainImageViews []*ImageView DepthImage *ImageResource DepthImageView *ImageView Framebuffers []vk.Framebuffer VKRenderPass vk.RenderPass // ConfigureRenderPass is a call back which can be supplied to // allow for custimization of the render pass ConfigureRenderPass func(renderPass vk.RenderPassCreateInfo) MakeCommandBuffer func(command *CommandBuffer, frame int) // contains filtered or unexported fields }
GraphicsApp is a utility object which implements many of the core requirements to get to a functioning Vulkan app. It will setup the appropriate devices and do many of the necissary preprations to begin drawing.
See https://vulkan-tutorial.com/ for a good walkthrough of what this code does.
func NewGraphicsApp ¶
func NewGraphicsApp(name string, version Version) (*GraphicsApp, error)
NewGraphicsApp creates a new graphics app with the given name and version
func (*GraphicsApp) AddGraphicsPipelineConfig ¶
func (p *GraphicsApp) AddGraphicsPipelineConfig(name string, config IGraphicsPipelineConfig)
AddGraphicsPipelineConfig adds this graphic pipeline config back into the app
func (*GraphicsApp) CreateGraphicsPipelineConfig ¶
func (p *GraphicsApp) CreateGraphicsPipelineConfig() *GraphicsPipelineConfig
CreateGraphicsPipelineConfig creates a graphic pipeline configuration for customization
func (*GraphicsApp) Destroy ¶
func (p *GraphicsApp) Destroy()
Destroy tears down the graphics application
func (*GraphicsApp) DrawFrameSync ¶
func (p *GraphicsApp) DrawFrameSync() error
DrawFrameSync draws one frame at a time to the GPU it does not utilize the GPU particularly well but simplifies application development because it insures that resources utilized by the created command buffers are not also utilized currently by the GPU. The specified call back is utilized to populate the command buffer.
The 'frame' parameter is provided so that the application may utilize multiple buffers if desired, although it should not be needed with this frame drawing method
See https://vulkan-tutorial.com/Uniform_buffers/Descriptor_layout_and_buffer for a discussion of how memory usage and frame drawing might require a more complex resource allocation approach
func (*GraphicsApp) EnableDebugging ¶
func (p *GraphicsApp) EnableDebugging() bool
EnableDebugging enables a list of commonly used debugging layers
func (*GraphicsApp) EnableExtension ¶
func (p *GraphicsApp) EnableExtension(extension string) bool
EnableExtension enables a specific extension
func (*GraphicsApp) EnableLayer ¶
func (p *GraphicsApp) EnableLayer(layer string) bool
EnableLayer enables a specific layer of the code
func (*GraphicsApp) GetScreenExtent ¶
func (p *GraphicsApp) GetScreenExtent() vk.Extent2D
GetScreenExtent gets the current screen extents
func (*GraphicsApp) NumFramebuffers ¶
func (p *GraphicsApp) NumFramebuffers() int
NumFramebuffers returns the number of framebuffers that have been created
func (*GraphicsApp) PhysicalDevices ¶
func (p *GraphicsApp) PhysicalDevices() ([]*PhysicalDevice, error)
PhysicalDevices returns a list of physical devices
func (*GraphicsApp) PrepareToDraw ¶
func (p *GraphicsApp) PrepareToDraw() error
PrepareToDraw creates the nescissary objects required to start drawing, it must be called after Init is called and after MakeCommandBuffers is set
func (*GraphicsApp) Resize ¶
func (p *GraphicsApp) Resize()
Resize is used to signal that we need to resize
func (*GraphicsApp) SetWindow ¶
func (p *GraphicsApp) SetWindow(window *glfw.Window) error
SetWindow sets the GLFW window for the graphics app
func (*GraphicsApp) SupportedExtensions ¶
func (p *GraphicsApp) SupportedExtensions() ([]string, error)
SupportedExtensions returns alist of supported extensions
func (*GraphicsApp) SupportedLayers ¶
func (p *GraphicsApp) SupportedLayers() ([]string, error)
SupportedLayers returns a list of supported layers
func (*GraphicsApp) VKRenderPassCreateInfo ¶
func (p *GraphicsApp) VKRenderPassCreateInfo() vk.RenderPassCreateInfo
VKRenderPassCreateInfo is a utility function which creates the render pass info, the implementing application can implement the ConfigureRenderPass function to customize the render pass
type GraphicsPipelineConfig ¶
type GraphicsPipelineConfig struct { Device *Device ShaderStages []vk.PipelineShaderStageCreateInfo VertexSource VertexSourcer DescriptorSetLayouts []*DescriptorSetLayout PipelineLayout *PipelineLayout // Called as the last step in config generation to allow for // additional configuration Configure func(config vk.GraphicsPipelineCreateInfo) // PrimativeTopology see https://www.khronos.org/registry/vulkan/specs/1.1-extensions/man/html/VkPrimitiveTopology.html // defaults to VK_PRIMITIVE_TOPOLOGY_TRIANGLE_LIST PrimitiveTopology vk.PrimitiveTopology // PrimativeRestartEnable see https://www.khronos.org/registry/vulkan/specs/1.1-extensions/man/html/VkPipelineInputAssemblyStateCreateInfo.html // defaults to False PrimitiveRestartEnable vk.Bool32 // PolygonMode see https://www.khronos.org/registry/vulkan/specs/1.1-extensions/man/html/VkPolygonMode.html // defaults to VK_POLYGON_MODE_FILL PolygonMode vk.PolygonMode // LineWidth of rasterized lines see https://www.khronos.org/registry/vulkan/specs/1.1-extensions/man/html/VkPipelineRasterizationStateCreateInfo.html // defaults to 1.0 LineWidth float32 // CullModes specifies which triangles will be culled. See https://www.khronos.org/registry/vulkan/specs/1.1/html/vkspec.html#VkCullModeFlagBits // Defaults to vk.CullModeBackBit CullMode vk.CullModeFlagBits // DynamicState specifies which part of the pipeline might be modified by the command buffer see // https://www.khronos.org/registry/vulkan/specs/1.1/html/vkspec.html#VkDynamicState // defaults to none DynamicState []vk.DynamicState // FrontFace specifies how the front face of a triangle is determined, see https://www.khronos.org/registry/vulkan/specs/1.1/html/vkspec.html#VkFrontFace // defaults to vk.FrontFaceCounterClockwise FrontFace vk.FrontFace // Add a pipeline color blend attachment state, by default it's assumed that all colors are set to no blending // see https://www.khronos.org/registry/vulkan/specs/1.1-extensions/man/html/VkPipelineColorBlendAttachmentState.html BlendAttachments []vk.PipelineColorBlendAttachmentState // DepthTestEnable defaults to true DepthTestEnable bool // DepthWriteEnable defaults to true DepthWriteEnable bool VertexInputBindingDescriptions []vk.VertexInputBindingDescription VertexInputAttributeDescriptions []vk.VertexInputAttributeDescription Viewport *vk.Viewport // contains filtered or unexported fields }
GraphicsPipelineConfig is a utility object to ease construction of graphics pipelines
func (*GraphicsPipelineConfig) AddBlendAttachment ¶
func (g *GraphicsPipelineConfig) AddBlendAttachment(ba vk.PipelineColorBlendAttachmentState)
AddBlendAttachment adds a new blend attachment
func (*GraphicsPipelineConfig) AddDescriptorSetLayout ¶
func (g *GraphicsPipelineConfig) AddDescriptorSetLayout(d *DescriptorSetLayout) *GraphicsPipelineConfig
AddDescriptorSetLayout adds a specific DescriptorSetLayout
func (*GraphicsPipelineConfig) AddShaderStageFromFile ¶
func (g *GraphicsPipelineConfig) AddShaderStageFromFile(file, entryPoint string, stageType vk.ShaderStageFlagBits) error
AddShaderStageFromFile adds a shader from a specified file
func (*GraphicsPipelineConfig) AddVertexDescriptor ¶
func (g *GraphicsPipelineConfig) AddVertexDescriptor(v VertexDescriptor) *GraphicsPipelineConfig
AddVertexDescriptor adds vertex descriptors based off the specified interface
func (*GraphicsPipelineConfig) Destroy ¶
func (g *GraphicsPipelineConfig) Destroy()
func (*GraphicsPipelineConfig) SetCullMode ¶
func (g *GraphicsPipelineConfig) SetCullMode(mode vk.CullModeFlagBits) *GraphicsPipelineConfig
SetCullMode sets the cull mode
func (*GraphicsPipelineConfig) SetDynamicState ¶
func (g *GraphicsPipelineConfig) SetDynamicState(states ...vk.DynamicState) *GraphicsPipelineConfig
SetDynamicState specifies which part of the pipeline may be changed with command buffer commands
func (*GraphicsPipelineConfig) SetPipelineLayout ¶
func (g *GraphicsPipelineConfig) SetPipelineLayout(layout *PipelineLayout) *GraphicsPipelineConfig
SetPipelineLayout sets the pipeline layout
func (*GraphicsPipelineConfig) SetShaderStages ¶
func (g *GraphicsPipelineConfig) SetShaderStages(shaderStages []vk.PipelineShaderStageCreateInfo) *GraphicsPipelineConfig
SetShaderStages sets the shader stages directly
func (*GraphicsPipelineConfig) VKGraphicsPipelineCreateInfo ¶
func (g *GraphicsPipelineConfig) VKGraphicsPipelineCreateInfo(extent vk.Extent2D) (vk.GraphicsPipelineCreateInfo, error)
VKGraphicsPipelineCreateInfo uses the provided config information to create a vulkank vk.GraphicsPipelineCreateInfo structure
type IAllocatedItem ¶
type IAllocatedItem interface { Destroy() String() string }
type IAllocator ¶
type IAllocator interface { Free(a *Allocation) Allocate(size uint64, align uint64) *Allocation Allocations() []*Allocation DestroyContents() LogDetails() }
IAllocator is an interface for generic memroy allocation, it can be utilized to provide a more powerful allocation capability than the currently implemented linear allocator Allocater
type IGraphicsPipelineConfig ¶
type IGraphicsPipelineConfig interface { VKGraphicsPipelineCreateInfo(screenExtents vk.Extent2D) (vk.GraphicsPipelineCreateInfo, error) Destroy() }
GraphicsPipelineConfigurer
type Image ¶
type Image struct { Device *Device VKImage vk.Image VKFormat vk.Format Size uint64 Extent vk.Extent2D }
Image is analogous to a buffer, it is essentially a designation that a resource is an image.
func (*Image) CreateImageView ¶
func (*Image) CreateImageViewWithAspectMask ¶
func (i *Image) CreateImageViewWithAspectMask(mask vk.ImageAspectFlags) (*ImageView, error)
func (*Image) VKMemoryRequirements ¶
func (d *Image) VKMemoryRequirements() vk.MemoryRequirements
VKMemoryRequirements return the memory requirements for the images
type ImageResource ¶
type ImageResource struct { Image ResourcePool *ImageResourcePool Allocation *Allocation StagingResource *BufferResource // Does this resource have it's own pool it is responsible for? IndividualPool bool }
func (*ImageResource) AllocateStagingResource ¶
func (r *ImageResource) AllocateStagingResource() error
AllocateStagingResource will allocate an apporpriate resource which can be used for staging this resource. Once allocated it must be explicitly free'd. The staging resource is allocated from a resource pool called 'staging', which the program must create
func (*ImageResource) Bytes ¶
func (r *ImageResource) Bytes() ([]byte, error)
Bytes returns a byte slice representing the mapped memory, which can be read from or copied to
func (*ImageResource) Destroy ¶
func (r *ImageResource) Destroy()
func (*ImageResource) Free ¶
func (r *ImageResource) Free()
Free this resource and it's associated resources
func (*ImageResource) FreeStagingResource ¶
func (r *ImageResource) FreeStagingResource()
FreeStagingResource will free the staged resource associated with this resource
func (*ImageResource) RequiresStaging ¶
func (r *ImageResource) RequiresStaging() bool
RequiresStaging indicates that this particular buffer resource must be staged before it can be used
func (*ImageResource) String ¶
func (r *ImageResource) String() string
type ImageResourcePool ¶
type ImageResourcePool struct { Device *Device Name string Usage vk.ImageUsageFlagBits Sharing vk.SharingMode MemoryProperties vk.MemoryPropertyFlagBits Size uint64 Allocator IAllocator Memory *DeviceMemory NeedsStaging bool ResourceManager *ResourceManager }
func (*ImageResourcePool) AllocateImage ¶
func (p *ImageResourcePool) AllocateImage(extent vk.Extent2D, format vk.Format, tiling vk.ImageTiling, usage vk.ImageUsageFlagBits) (*ImageResource, error)
func (*ImageResourcePool) Destroy ¶
func (p *ImageResourcePool) Destroy()
func (*ImageResourcePool) LogDetails ¶
func (p *ImageResourcePool) LogDetails()
func (*ImageResourcePool) StageTextureFromDisk ¶
func (p *ImageResourcePool) StageTextureFromDisk(filename string, cmd *CommandBuffer, queue *Queue) (*ImageResource, error)
func (*ImageResourcePool) StageTextureFromImage ¶
func (p *ImageResourcePool) StageTextureFromImage(srcImg *image.RGBA, cmd *CommandBuffer, queue *Queue) (*ImageResource, error)
type IndexSliceUint16 ¶
type IndexSliceUint16 []uint16
func (IndexSliceUint16) Bytes ¶
func (i IndexSliceUint16) Bytes() []byte
func (IndexSliceUint16) IndexType ¶
func (i IndexSliceUint16) IndexType() vk.IndexType
type IndexSliceUint32 ¶
type IndexSliceUint32 []uint16
func (IndexSliceUint32) Bytes ¶
func (i IndexSliceUint32) Bytes() []byte
func (IndexSliceUint32) IndexType ¶
func (i IndexSliceUint32) IndexType() vk.IndexType
type IndexSourcer ¶
type IndexSourcer interface { ByteSourcer IndexType() vk.IndexType }
type Instance ¶
Instance is an instance of the Vulkan subsystem
func (*Instance) PhysicalDevices ¶
func (i *Instance) PhysicalDevices() ([]*PhysicalDevice, error)
PhysicalDevices returns a list of physical devices known to Vulkan
func (*Instance) SetDebugCallback ¶
func (i *Instance) SetDebugCallback(callback vk.DebugReportCallbackFunc) error
func (*Instance) UseDefaultDebugCallback ¶
func (i *Instance) UseDefaultDebugCallback()
type LinearAllocator ¶
type LinearAllocator struct { Size uint64 // contains filtered or unexported fields }
LinearAllocator is a basic linear allocator for memory, it simply allocates blocks of memory and will return the first allocation that that fits the request, it's not ideal, but works.
func (*LinearAllocator) Allocate ¶
func (p *LinearAllocator) Allocate(size uint64, align uint64) *Allocation
Allocate a new hunk of memory
func (*LinearAllocator) Allocations ¶
func (p *LinearAllocator) Allocations() []*Allocation
func (*LinearAllocator) DestroyContents ¶
func (p *LinearAllocator) DestroyContents()
func (*LinearAllocator) Free ¶
func (p *LinearAllocator) Free(fa *Allocation)
Free the specified allocation
func (*LinearAllocator) LogDetails ¶
func (p *LinearAllocator) LogDetails()
func (*LinearAllocator) String ¶
func (p *LinearAllocator) String() string
String for stringer interface
type MappedMemoryRange ¶
type MappedMemoryRange interface {
VKMappedMemoryRange() vk.MappedMemoryRange
}
type MemoryTypeSlice ¶
type MemoryTypeSlice []vk.MemoryType
func (MemoryTypeSlice) Filter ¶
func (m MemoryTypeSlice) Filter(f func(properties vk.MemoryPropertyFlagBits) bool) MemoryTypeSlice
func (MemoryTypeSlice) NumHostCoherent ¶
func (m MemoryTypeSlice) NumHostCoherent() int
func (MemoryTypeSlice) NumHostVisible ¶
func (m MemoryTypeSlice) NumHostVisible() int
func (MemoryTypeSlice) NumHostVisibleAndCoherent ¶
func (m MemoryTypeSlice) NumHostVisibleAndCoherent() int
type PhysicalDevice ¶
type PhysicalDevice struct { DeviceName string VKPhysicalDevice vk.PhysicalDevice VKPhysicalDeviceProperties vk.PhysicalDeviceProperties }
func (*PhysicalDevice) CreateLogicalDevice ¶
func (p *PhysicalDevice) CreateLogicalDevice(qfs QueueFamilySlice) (*Device, error)
func (*PhysicalDevice) CreateLogicalDeviceWithOptions ¶
func (p *PhysicalDevice) CreateLogicalDeviceWithOptions(qfs QueueFamilySlice, options *CreateDeviceOptions) (*Device, error)
func (*PhysicalDevice) FindMemoryType ¶
func (p *PhysicalDevice) FindMemoryType(memoryTypeBits uint32, properties vk.MemoryPropertyFlagBits) (uint32, error)
func (*PhysicalDevice) GetSurfaceCapabilities ¶
func (p *PhysicalDevice) GetSurfaceCapabilities(surface vk.Surface) (*vk.SurfaceCapabilities, error)
func (*PhysicalDevice) GetSurfaceFormats ¶
func (p *PhysicalDevice) GetSurfaceFormats(surface vk.Surface) (VKSurfaceFormats, error)
func (*PhysicalDevice) GetSurfacePresentModes ¶
func (p *PhysicalDevice) GetSurfacePresentModes(surface vk.Surface) (VKPresentModes, error)
func (*PhysicalDevice) MemoryTypes ¶
func (p *PhysicalDevice) MemoryTypes() []vk.MemoryType
func (*PhysicalDevice) QueueFamilies ¶
func (p *PhysicalDevice) QueueFamilies() (QueueFamilySlice, error)
func (*PhysicalDevice) String ¶
func (p *PhysicalDevice) String() string
func (*PhysicalDevice) SupportedExtensions ¶
func (p *PhysicalDevice) SupportedExtensions() ([]vk.ExtensionProperties, error)
func (*PhysicalDevice) VKPhysicalDeviceFeatures ¶
func (p *PhysicalDevice) VKPhysicalDeviceFeatures() vk.PhysicalDeviceFeatures
func (*PhysicalDevice) VKPhysicalDeviceMemoryProperties ¶
func (p *PhysicalDevice) VKPhysicalDeviceMemoryProperties() vk.PhysicalDeviceMemoryProperties
type PipelineCache ¶
type PipelineCache struct { Device *Device VKPipelineCache vk.PipelineCache }
func (*PipelineCache) Destroy ¶
func (c *PipelineCache) Destroy()
type PipelineLayout ¶
type PipelineLayout struct { Device *Device VKPipelineLayout vk.PipelineLayout }
func (*PipelineLayout) Destroy ¶
func (p *PipelineLayout) Destroy()
type Queue ¶
type Queue struct { Device *Device QueueFamily *QueueFamily VKQueue vk.Queue }
func (*Queue) SubmitWaitIdle ¶
func (q *Queue) SubmitWaitIdle(buffers ...*CommandBuffer) error
func (*Queue) SubmitWithFence ¶
func (q *Queue) SubmitWithFence(fence *Fence, buffers ...*CommandBuffer) error
type QueueFamily ¶
type QueueFamily struct { Index int PhysicalDevice *PhysicalDevice VKQueueFamilyProperties vk.QueueFamilyProperties }
func (*QueueFamily) IsCompute ¶
func (q *QueueFamily) IsCompute() bool
func (*QueueFamily) IsGraphics ¶
func (q *QueueFamily) IsGraphics() bool
func (*QueueFamily) IsTransfer ¶
func (q *QueueFamily) IsTransfer() bool
func (*QueueFamily) String ¶
func (q *QueueFamily) String() string
func (*QueueFamily) SupportsPresent ¶
func (q *QueueFamily) SupportsPresent(surface vk.Surface) bool
type QueueFamilySlice ¶
type QueueFamilySlice []*QueueFamily
func (QueueFamilySlice) Filter ¶
func (ql QueueFamilySlice) Filter(f func(q *QueueFamily) bool) QueueFamilySlice
func (QueueFamilySlice) FilterCompute ¶
func (ql QueueFamilySlice) FilterCompute() QueueFamilySlice
func (QueueFamilySlice) FilterGraphics ¶
func (ql QueueFamilySlice) FilterGraphics() QueueFamilySlice
func (QueueFamilySlice) FilterGraphicsAndPresent ¶
func (ql QueueFamilySlice) FilterGraphicsAndPresent(surface vk.Surface) QueueFamilySlice
func (QueueFamilySlice) FilterPresent ¶
func (ql QueueFamilySlice) FilterPresent(surface vk.Surface) QueueFamilySlice
func (QueueFamilySlice) FilterTransfer ¶
func (ql QueueFamilySlice) FilterTransfer() QueueFamilySlice
type ResourceManager ¶
type ResourceManager struct { Device *Device // contains filtered or unexported fields }
func (*ResourceManager) AllocateBufferPoolWithOptions ¶
func (r *ResourceManager) AllocateBufferPoolWithOptions(name string, size uint64, mprops vk.MemoryPropertyFlagBits, usage vk.BufferUsageFlagBits, sharing vk.SharingMode) (*BufferResourcePool, error)
func (*ResourceManager) AllocateDeviceTexturePool ¶
func (r *ResourceManager) AllocateDeviceTexturePool(name string, size uint64) (*ImageResourcePool, error)
func (*ResourceManager) AllocateHostVertexAndIndexBufferPool ¶
func (r *ResourceManager) AllocateHostVertexAndIndexBufferPool(name string, size uint64) (*BufferResourcePool, error)
func (*ResourceManager) AllocateImagePoolWithOptions ¶
func (r *ResourceManager) AllocateImagePoolWithOptions(name string, size uint64, mprops vk.MemoryPropertyFlagBits, usage vk.ImageUsageFlagBits, sharing vk.SharingMode) (*ImageResourcePool, error)
func (*ResourceManager) AllocateStagingPool ¶
func (r *ResourceManager) AllocateStagingPool(size uint64) (*BufferResourcePool, error)
func (*ResourceManager) BufferPool ¶
func (r *ResourceManager) BufferPool(name string) *BufferResourcePool
func (*ResourceManager) Destroy ¶
func (r *ResourceManager) Destroy()
func (*ResourceManager) GetStagingPool ¶
func (r *ResourceManager) GetStagingPool() *BufferResourcePool
func (*ResourceManager) HasStagingPool ¶
func (r *ResourceManager) HasStagingPool() bool
func (*ResourceManager) ImagePool ¶
func (r *ResourceManager) ImagePool(name string) *ImageResourcePool
func (*ResourceManager) LogDetails ¶
func (r *ResourceManager) LogDetails()
func (*ResourceManager) NewImageResourceWithOptions ¶
func (r *ResourceManager) NewImageResourceWithOptions(extent vk.Extent2D, format vk.Format, tiling vk.ImageTiling, usage vk.ImageUsageFlagBits, sharing vk.SharingMode, mprops vk.MemoryPropertyFlagBits) (*ImageResource, error)
NewImageResourceWithOptions will create a image resource which has it's own exclusive pool
type ShaderModule ¶
type ShaderModule struct { Device *Device Description string VKShaderModule vk.ShaderModule }
func (*ShaderModule) Destroy ¶
func (s *ShaderModule) Destroy()
func (*ShaderModule) VKPipelineShaderStageCreateInfo ¶
func (s *ShaderModule) VKPipelineShaderStageCreateInfo(stage vk.ShaderStageFlagBits, entryPoint string) vk.PipelineShaderStageCreateInfo
type Swapchain ¶
type UpdateFrequencyType ¶
type UpdateFrequencyType int
const ( // If this object is put into device memory it will be tossed from host memory? Once UpdateFrequencyType = iota // We will potentialy pause the draw frame to update this Occasionally // We will assume this item needs to be updated almost every frame Frequently )
type VKBufferProvider ¶
type VKImageProvider ¶
type VKPresentModes ¶
type VKPresentModes []vk.PresentMode
func (VKPresentModes) Filter ¶
func (v VKPresentModes) Filter(f vk.PresentMode) VKPresentModes
type VKSurfaceFormats ¶
type VKSurfaceFormats []vk.SurfaceFormat
func (VKSurfaceFormats) Filter ¶
func (v VKSurfaceFormats) Filter(f func(f vk.SurfaceFormat) bool) VKSurfaceFormats
type VertexDescriptor ¶
type VertexDescriptor interface { GetBindingDescription() vk.VertexInputBindingDescription GetAttributeDescriptions() []vk.VertexInputAttributeDescription }
type VertexSourcer ¶
type VertexSourcer interface { ByteSourcer VertexDescriptor }
Source Files ¶
- allocator.go
- buffer.go
- bufferresource.go
- commandbuffer.go
- commandpool.go
- data.go
- descriptorpool.go
- descriptorset.go
- descriptorsetlayout.go
- device.go
- devicememory.go
- docs.go
- editor.go
- fence.go
- graphicsapp.go
- graphicspipelineconfig.go
- image.go
- imageresource.go
- imageview.go
- instance.go
- interfaces.go
- physicaldevice.go
- pipeline.go
- pipelinelayout.go
- queue.go
- queuefamily.go
- resourcemanager.go
- semaphore.go
- shader.go
- swapchain.go
- textureutil.go
- utils.go