Documentation
¶
Overview ¶
Package vulkan is the Vulkan backend of the explicit renderer (SPEC §9.4): it loads libvulkan.so.1 through purego and implements explicit.Device on it. It has no cgo, and no Vulkan type leaves the package.
Flutter: Impeller's Vulkan backend (engine/src/flutter/impeller/renderer/backend/vulkan).
Index ¶
- type Device
- func (d *Device) Begin() (explicit.Encoder, error)
- func (d *Device) Close() error
- func (d *Device) Description() string
- func (d *Device) DeviceName() string
- func (d *Device) Limits() explicit.Limits
- func (d *Device) NewBindGroup(p explicit.Pipeline, group int, entries []explicit.Binding) (explicit.BindGroup, error)
- func (d *Device) NewBuffer(size int, usage explicit.BufferUsage) (explicit.Buffer, error)
- func (d *Device) NewPipeline(desc explicit.PipelineDesc) (explicit.Pipeline, error)
- func (d *Device) NewSampler(desc explicit.SamplerDesc) (explicit.Sampler, error)
- func (d *Device) NewSwapchain(h gpu.SurfaceHandle) (explicit.Swapchain, error)
- func (d *Device) NewTexture(desc explicit.TextureDesc) (explicit.Texture, error)
- func (d *Device) ValidationErrors() []string
- func (d *Device) WriteBuffer(b explicit.Buffer, offset int, data []byte)
- func (d *Device) WriteTexture(t explicit.Texture, level int, r image.Rectangle, data []byte, stride int)
- type Options
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Device ¶
type Device struct {
// contains filtered or unexported fields
}
Device is a Vulkan device and its queue: an explicit.Device. It is used on the UI thread only.
Flutter: no counterpart
func Open ¶
Open loads Vulkan, makes the instance, chooses the physical device and makes the logical device and its queue (SPEC §9.4). It fails with:
- VulkanLoadFailed when libvulkan.so.1 cannot be loaded
- VulkanUnsupported when the loader, or every device, lacks the version, the extensions or the features that Glutter needs
- VulkanNoDevice when there is no device that can be used
- GPUOutOfMemory when the driver is out of memory
Flutter: no counterpart
func (*Device) Begin ¶
Begin implements explicit.Device: it waits for the slot of the frame if the GPU is still using it, and starts its command buffer with what was queued since the last frame (the layouts of new textures, uploads). It fails with VulkanFrameOpen when the previous frame was not submitted.
func (*Device) Close ¶
Close waits for the GPU, destroys everything that was made with the device and the instance. It can be called twice.
Flutter: no counterpart
func (*Device) Description ¶
Description names the backend and the device: "vulkan: Intel(R) Graphics (ADL GT2)".
Flutter: no counterpart
func (*Device) NewBindGroup ¶
func (d *Device) NewBindGroup(p explicit.Pipeline, group int, entries []explicit.Binding) (explicit.BindGroup, error)
NewBindGroup implements explicit.Device: the set is made from the descriptor pool of the frame that is being recorded, or of the next one.
func (*Device) NewPipeline ¶
NewPipeline implements explicit.Device: the descriptor set layouts come from the bindings of the two entry points, uniform buffers with dynamic offsets (SPEC §9.3).
func (*Device) NewSampler ¶
NewSampler implements explicit.Device.
func (*Device) NewSwapchain ¶
NewSwapchain implements explicit.Device: it makes the surface of the window and the swapchain object; the images come with Configure. It fails with VulkanSurfaceFailed when the window cannot be drawn into with Vulkan.
func (*Device) NewTexture ¶
NewTexture implements explicit.Device. The image is made in the GENERAL layout, in which it is drawn into, sampled and copied from and to; the transition is recorded in the next frame, or in the one being recorded.
func (*Device) ValidationErrors ¶
ValidationErrors returns the errors that the validation layer reported so far, when validation is on.
Flutter: no counterpart
func (*Device) WriteBuffer ¶
WriteBuffer implements explicit.Device: the memory is mapped and coherent, so the data is copied at once.
func (*Device) WriteTexture ¶
func (d *Device) WriteTexture(t explicit.Texture, level int, r image.Rectangle, data []byte, stride int)
WriteTexture implements explicit.Device: the rows are copied into the staging ring and copied into the image by a command of the next frame, or of the frame being recorded when it is between passes. A failure to stage the data panics: it is out of memory, which Device methods that return no error cannot report.
type Options ¶
type Options struct {
// Logger gets the log of the backend, and the messages of the validation layer;
// slog.Default() when nil.
Logger *slog.Logger
// Getenv reads the environment (GLUTTER_VULKAN_LIBRARY, GLUTTER_VULKAN_DEVICE,
// GLUTTER_VULKAN_VALIDATION); os.Getenv when nil.
Getenv func(string) string
// AllowCPU lets a device of type CPU (lavapipe) be used: the engine sets it when
// Vulkan is asked for by name (SPEC §9.4).
AllowCPU bool
// Validation turns on the validation layer, as GLUTTER_VULKAN_VALIDATION=1 does.
Validation bool
// Surface, when its Kind is set, is the first window: the device is chosen among those
// that can present to it, and has the swapchain extension. Without it the device draws
// offscreen only.
Surface gpu.SurfaceHandle
}
Options are what Open takes.
Flutter: no counterpart