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) SavePipelineCache()
- func (d *Device) StartupReport() gpu.StartupReport
- 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 DriverInfo
- type Options
- type PipelineCache
- type Vendor
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) SavePipelineCache ¶
func (d *Device) SavePipelineCache()
SavePipelineCache gives the data of the pipeline cache to the store, when it has grown since it was loaded or last saved. The renderer calls it after the first frame and the device at Close, so that a second start finds the pipelines that the first one needed.
Flutter: no counterpart
func (*Device) StartupReport ¶
func (d *Device) StartupReport() gpu.StartupReport
StartupReport says how the start went: how long Open took, and the pipelines made so far.
Flutter: no counterpart
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 DriverInfo ¶
type DriverInfo struct {
// Name is deviceName: "Adreno (TM) 650", "Mali-G78", "PowerVR CXT 48-1536".
Name string
// VendorID, DeviceID and DriverVersion are the fields of VkPhysicalDeviceProperties.
VendorID, DeviceID, DriverVersion uint32
// APIVersion is the packed Vulkan version the device supports.
APIVersion uint32
}
DriverInfo is what the deny list looks at: the properties of the physical device that the choice took.
Flutter: impeller/renderer/backend/vulkan/driver_info_vk.h DriverInfoVK
func (DriverInfo) IsKnownBadDriver ¶
func (d DriverInfo) IsKnownBadDriver() (bad bool, reason string)
IsKnownBadDriver says whether the driver is on the list of drivers that Vulkan is not used with on Android: the Pixel 10 with a PowerVR driver older than 25.1, Adreno 650 and older, the Huawei Maleoon, Samsung's Xclipse below Vulkan 1.3 and PowerVR below the CXT series.
Deviation: Impeller reads the PowerVR series only when the vendor is kPowerVR, a value that its IdentifyVendor never returns (the vendor ID 0x1010 is kImgTec), so its PowerVR rules never apply; here they apply to the vendor ID 0x1010, which is what they say. SPEC §12.10.
Flutter: impeller/renderer/backend/vulkan/driver_info_vk.cc DriverInfoVK::IsKnownBadDriver
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
// DenyKnownBad refuses a device whose driver is on the list that Flutter's Impeller keeps
// (DriverInfo.IsKnownBadDriver): the engine sets it for `auto` on Android, so that GLES is used
// instead (SPEC §24.4). Vulkan asked for by name leaves it off.
DenyKnownBad 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
// PipelineCache keeps the pipeline cache between runs (SPEC §9.7); none makes every pipeline from scratch.
PipelineCache PipelineCache
}
Options are what Open takes.
Flutter: no counterpart
type PipelineCache ¶
PipelineCache keeps the data of the Vulkan pipeline cache between runs: shadercache.Cache is one. A Store that fails is the cache's business (it reports it once); the device goes on (SPEC §9.7).
Flutter: no counterpart