Documentation
¶
Overview ¶
Package wgpu provides a safe, ergonomic WebGPU API for Go applications.
This package wraps the lower-level hal/ and core/ packages into a user-friendly API aligned with the W3C WebGPU specification.
Quick Start ¶
Import this package and a backend registration package:
import (
"github.com/roffe/gowgpu"
_ "github.com/roffe/gowgpu/hal/allbackends"
)
instance, err := wgpu.CreateInstance(nil)
// ...
Resource Lifecycle ¶
All GPU resources must be explicitly released with Release(). Resources are reference-counted internally. Using a released resource panics.
Backend Registration ¶
Backends are registered via blank imports:
_ "github.com/roffe/gowgpu/hal/allbackends" // all available backends _ "github.com/roffe/gowgpu/hal/vulkan" // Vulkan only _ "github.com/roffe/gowgpu/hal/noop" // testing
Thread Safety ¶
Instance, Adapter, and Device are safe for concurrent use. Encoders (CommandEncoder, RenderPassEncoder, ComputePassEncoder) are NOT thread-safe.
Index ¶
- Constants
- Variables
- func Logger() *slog.Logger
- func SetLogger(l *slog.Logger)
- type Adapter
- func (a *Adapter) DownlevelCapabilities() gputypes.DownlevelCapabilities
- func (a *Adapter) Features() gputypes.Features
- func (a *Adapter) GetSurfaceCapabilities(surface *Surface) *SurfaceCapabilities
- func (a *Adapter) Info() gputypes.AdapterInfo
- func (a *Adapter) Limits() gputypes.Limits
- func (a *Adapter) Release()
- func (a *Adapter) RequestDevice(desc *DeviceDescriptor) (*Device, error)
- type BindGroup
- type BindGroupDescriptor
- type BindGroupEntry
- type BindGroupLayout
- type BindGroupLayoutDescriptor
- type Buffer
- func (b *Buffer) Label() string
- func (b *Buffer) Map(ctx context.Context, mode MapMode, offset, size uint64) error
- func (b *Buffer) MapAsync(mode MapMode, offset, size uint64) (*MapPending, error)
- func (b *Buffer) MapState() MapState
- func (b *Buffer) MappedRange(offset, size uint64) (*MappedRange, error)
- func (b *Buffer) Release()
- func (b *Buffer) Size() uint64
- func (b *Buffer) Unmap() error
- func (b *Buffer) Usage() gputypes.BufferUsage
- type BufferDescriptor
- type BufferTextureCopy
- type CommandBuffer
- type CommandEncoder
- func (e *CommandEncoder) BeginComputePass(desc *ComputePassDescriptor) (*ComputePassEncoder, error)
- func (e *CommandEncoder) BeginRenderPass(desc *RenderPassDescriptor) (*RenderPassEncoder, error)
- func (e *CommandEncoder) ClearBuffer(buffer *Buffer, offset, size uint64)
- func (e *CommandEncoder) CopyBufferToBuffer(src *Buffer, srcOffset uint64, dst *Buffer, dstOffset uint64, size uint64)
- func (e *CommandEncoder) CopyBufferToTexture(src *Buffer, dst *Texture, regions []BufferTextureCopy)
- func (e *CommandEncoder) CopyTextureToBuffer(src *Texture, dst *Buffer, regions []BufferTextureCopy)
- func (e *CommandEncoder) CopyTextureToTexture(src, dst *Texture, regions []TextureCopy)
- func (e *CommandEncoder) DiscardEncoding()
- func (e *CommandEncoder) Finish() (_ *CommandBuffer, err error)
- func (e *CommandEncoder) ResolveQuerySet(querySet *QuerySet, firstQuery, queryCount uint32, dst *Buffer, ...)
- func (e *CommandEncoder) TransitionTextures(barriers []TextureBarrier)
- type CommandEncoderDescriptor
- type ComputePassDescriptor
- type ComputePassEncoder
- func (p *ComputePassEncoder) Dispatch(x, y, z uint32)
- func (p *ComputePassEncoder) DispatchIndirect(buffer *Buffer, offset uint64)
- func (p *ComputePassEncoder) End() error
- func (p *ComputePassEncoder) SetBindGroup(index uint32, group *BindGroup, offsets []uint32)
- func (p *ComputePassEncoder) SetPipeline(pipeline *ComputePipeline)
- type ComputePassTimestampWrites
- type ComputePipeline
- type ComputePipelineDescriptor
- type DepthStencilState
- type Device
- func (d *Device) CreateBindGroup(desc *BindGroupDescriptor) (_ *BindGroup, err error)
- func (d *Device) CreateBindGroupLayout(desc *BindGroupLayoutDescriptor) (_ *BindGroupLayout, err error)
- func (d *Device) CreateBuffer(desc *BufferDescriptor) (_ *Buffer, err error)
- func (d *Device) CreateCommandEncoder(desc *CommandEncoderDescriptor) (_ *CommandEncoder, err error)
- func (d *Device) CreateComputePipeline(desc *ComputePipelineDescriptor) (_ *ComputePipeline, err error)
- func (d *Device) CreateFence() (*Fence, error)
- func (d *Device) CreatePipelineLayout(desc *PipelineLayoutDescriptor) (_ *PipelineLayout, err error)
- func (d *Device) CreateQuerySet(desc *QuerySetDescriptor) (_ *QuerySet, err error)
- func (d *Device) CreateRenderBundleEncoder(desc *RenderBundleEncoderDescriptor) (_ *RenderBundleEncoder, err error)
- func (d *Device) CreateRenderPipeline(desc *RenderPipelineDescriptor) (_ *RenderPipeline, err error)
- func (d *Device) CreateSampler(desc *SamplerDescriptor) (_ *Sampler, err error)
- func (d *Device) CreateShaderModule(desc *ShaderModuleDescriptor) (_ *ShaderModule, err error)
- func (d *Device) CreateTexture(desc *TextureDescriptor) (_ *Texture, err error)
- func (d *Device) CreateTextureView(texture *Texture, desc *TextureViewDescriptor) (_ *TextureView, err error)
- func (d *Device) DestroyFence(f *Fence)deprecated
- func (d *Device) Features() gputypes.Features
- func (d *Device) FreeCommandBuffer(cb *CommandBuffer)
- func (d *Device) GetFenceStatus(f *Fence) (bool, error)
- func (d *Device) HalDevice() hal.Device
- func (d *Device) Limits() gputypes.Limits
- func (d *Device) Poll(pollType PollType) bool
- func (d *Device) PopErrorScope() *GPUError
- func (d *Device) PushErrorScope(filter ErrorFilter)
- func (d *Device) Queue() *Queue
- func (d *Device) Release()
- func (d *Device) ResetFence(f *Fence) error
- func (d *Device) SetUncapturedErrorHandler(handler func(*GPUError))
- func (d *Device) WaitForFence(f *Fence, value uint64, timeout time.Duration) (bool, error)
- func (d *Device) WaitIdle() error
- type DeviceDescriptor
- type ErrorFilter
- type Extent3D
- type ExternalBuffer
- type ExternalImage
- type Fence
- type FragmentState
- type GPUError
- type ImageCopyTexture
- type ImageDataLayout
- type Instance
- func (i *Instance) CreateSurface(displayHandle, windowHandle uintptr) (*Surface, error)
- func (i *Instance) CreateSurfaceFromTarget(target SurfaceTarget) (*Surface, error)
- func (i *Instance) CreateSurfaceUnsafe(target SurfaceTargetUnsafe) (*Surface, error)
- func (i *Instance) Release()
- func (i *Instance) RequestAdapter(opts *RequestAdapterOptions) (*Adapter, error)
- type InstanceDescriptor
- type LateBufferBindingInfo
- type LateSizedBufferGroup
- type MapMode
- type MapPending
- type MapState
- type MappedRange
- type Origin3D
- type PipelineLayout
- type PipelineLayoutDescriptor
- type PollType
- type QuerySet
- type QuerySetDescriptor
- type QueryType
- type Queue
- func (q *Queue) CopyExternalBuffer(src ExternalBuffer, dst *Texture) error
- func (q *Queue) CopyExternalPlanes(src ExternalImage, dsts ...*Texture) (uint32, error)
- func (q *Queue) LastSubmissionIndex() uint64
- func (q *Queue) Poll() uint64
- func (q *Queue) ResolveBuffer(idx track.TrackerIndex) hal.Buffer
- func (q *Queue) ResolveTexture(idx track.TrackerIndex) hal.Texture
- func (q *Queue) SetSwapchainSuppressed(suppressed bool)
- func (q *Queue) Submit(commandBuffers ...*CommandBuffer) (_ uint64, err error)
- func (q *Queue) TimestampPeriod() float32
- func (q *Queue) WriteBuffer(buffer *Buffer, offset uint64, data []byte) (err error)
- func (q *Queue) WriteTexture(dst *ImageCopyTexture, data []byte, layout *ImageDataLayout, size *Extent3D) (err error)
- type RenderBundle
- type RenderBundleDescriptor
- type RenderBundleEncoder
- func (e *RenderBundleEncoder) Draw(args gputypes.DrawArgs)
- func (e *RenderBundleEncoder) DrawIndexed(args gputypes.DrawIndexedArgs)
- func (e *RenderBundleEncoder) Finish(desc *RenderBundleDescriptor) (_ *RenderBundle, err error)
- func (e *RenderBundleEncoder) SetBindGroup(index uint32, group *BindGroup, offsets []uint32)
- func (e *RenderBundleEncoder) SetIndexBuffer(buffer *Buffer, format gputypes.IndexFormat, offset uint64)
- func (e *RenderBundleEncoder) SetPipeline(pipeline *RenderPipeline)
- func (e *RenderBundleEncoder) SetVertexBuffer(slot uint32, buffer *Buffer, offset uint64)
- type RenderBundleEncoderDescriptor
- type RenderPassColorAttachment
- type RenderPassDepthStencilAttachment
- type RenderPassDescriptor
- type RenderPassEncoder
- func (p *RenderPassEncoder) Draw(args gputypes.DrawArgs)
- func (p *RenderPassEncoder) DrawIndexed(args gputypes.DrawIndexedArgs)
- func (p *RenderPassEncoder) DrawIndexedIndirect(buffer *Buffer, offset uint64)
- func (p *RenderPassEncoder) DrawIndirect(buffer *Buffer, offset uint64)
- func (p *RenderPassEncoder) End() error
- func (p *RenderPassEncoder) ExecuteBundles(bundles ...*RenderBundle)
- func (p *RenderPassEncoder) MultiDrawIndexedIndirect(buffer *Buffer, offset uint64, drawCount uint32)
- func (p *RenderPassEncoder) MultiDrawIndexedIndirectCount(indirectBuffer *Buffer, indirectOffset uint64, countBuffer *Buffer, ...)
- func (p *RenderPassEncoder) MultiDrawIndirect(buffer *Buffer, offset uint64, drawCount uint32)
- func (p *RenderPassEncoder) MultiDrawIndirectCount(indirectBuffer *Buffer, indirectOffset uint64, countBuffer *Buffer, ...)
- func (p *RenderPassEncoder) SetBindGroup(index uint32, group *BindGroup, offsets []uint32)
- func (p *RenderPassEncoder) SetBlendConstant(color *gputypes.Color)
- func (p *RenderPassEncoder) SetIndexBuffer(buffer *Buffer, format gputypes.IndexFormat, offset uint64)
- func (p *RenderPassEncoder) SetPipeline(pipeline *RenderPipeline)
- func (p *RenderPassEncoder) SetScissorRect(rect gputypes.ScissorRect)
- func (p *RenderPassEncoder) SetStencilReference(reference uint32)
- func (p *RenderPassEncoder) SetVertexBuffer(slot uint32, buffer *Buffer, offset uint64)
- func (p *RenderPassEncoder) SetViewport(vp gputypes.Viewport)
- type RenderPassTimestampWrites
- type RenderPipeline
- type RenderPipelineDescriptor
- type RequestAdapterOptions
- type Sampler
- type SamplerDescriptor
- type ShaderModule
- type ShaderModuleDescriptor
- type StencilFaceState
- type Surface
- func (s *Surface) ActualExtent() (width, height uint32)
- func (s *Surface) Configure(device *Device, config *SurfaceConfiguration) (err error)
- func (s *Surface) DiscardTexture()
- func (s *Surface) GetCurrentTexture() (*SurfaceTexture, bool, error)
- func (s *Surface) HAL() hal.Surface
- func (s *Surface) Present(texture *SurfaceTexture) error
- func (s *Surface) PresentWithDamage(texture *SurfaceTexture, damageRects []image.Rectangle) error
- func (s *Surface) Release()
- func (s *Surface) SetPrepareFrame(fn core.PrepareFrameFunc)
- func (s *Surface) SetPresentsWithTransaction(enabled bool)
- func (s *Surface) Unconfigure()
- type SurfaceCapabilities
- type SurfaceConfiguration
- type SurfaceTarget
- type SurfaceTargetUnsafe
- func SurfaceTargetFromAndroidNativeWindow(window uintptr) SurfaceTargetUnsafe
- func SurfaceTargetFromMetalLayer(layer uintptr) SurfaceTargetUnsafe
- func SurfaceTargetFromWaylandSurface(display, surface uintptr) SurfaceTargetUnsafe
- func SurfaceTargetFromWebCanvasID(id uintptr) SurfaceTargetUnsafe
- func SurfaceTargetFromWindowsHWND(hinstance, hwnd uintptr) SurfaceTargetUnsafe
- func SurfaceTargetFromXlibWindow(display, window uintptr) SurfaceTargetUnsafe
- type SurfaceTexture
- type Texture
- type TextureBarrier
- type TextureCopy
- type TextureDescriptor
- type TextureRange
- type TextureUsageTransition
- type TextureView
- type TextureViewDescriptor
- type VertexState
Constants ¶
const ( QueryTypeOcclusion = hal.QueryTypeOcclusion QueryTypeTimestamp = hal.QueryTypeTimestamp )
Query type constants.
const ( StencilOperationKeep = gputypes.StencilOperationKeep StencilOperationZero = gputypes.StencilOperationZero StencilOperationReplace = gputypes.StencilOperationReplace StencilOperationInvert = gputypes.StencilOperationInvert StencilOperationIncrementClamp = gputypes.StencilOperationIncrementClamp StencilOperationDecrementClamp = gputypes.StencilOperationDecrementClamp StencilOperationIncrementWrap = gputypes.StencilOperationIncrementWrap StencilOperationDecrementWrap = gputypes.StencilOperationDecrementWrap )
Stencil operation constants (webgpu.h spec values).
const ( ErrorFilterValidation = core.ErrorFilterValidation ErrorFilterOutOfMemory = core.ErrorFilterOutOfMemory ErrorFilterInternal = core.ErrorFilterInternal )
const ( BackendVulkan = gputypes.BackendVulkan BackendMetal = gputypes.BackendMetal BackendDX12 = gputypes.BackendDX12 BackendGL = gputypes.BackendGL )
Backend constants
const ( BackendsAll = gputypes.BackendsAll BackendsPrimary = gputypes.BackendsPrimary BackendsVulkan = gputypes.BackendsVulkan BackendsMetal = gputypes.BackendsMetal BackendsDX12 = gputypes.BackendsDX12 BackendsGL = gputypes.BackendsGL )
Backends masks
const ( BufferUsageMapRead = gputypes.BufferUsageMapRead BufferUsageMapWrite = gputypes.BufferUsageMapWrite BufferUsageCopySrc = gputypes.BufferUsageCopySrc BufferUsageCopyDst = gputypes.BufferUsageCopyDst BufferUsageIndex = gputypes.BufferUsageIndex BufferUsageVertex = gputypes.BufferUsageVertex BufferUsageUniform = gputypes.BufferUsageUniform BufferUsageStorage = gputypes.BufferUsageStorage BufferUsageIndirect = gputypes.BufferUsageIndirect BufferUsageQueryResolve = gputypes.BufferUsageQueryResolve )
Buffer usage constants
const ( TextureUsageCopySrc = gputypes.TextureUsageCopySrc TextureUsageCopyDst = gputypes.TextureUsageCopyDst TextureUsageTextureBinding = gputypes.TextureUsageTextureBinding TextureUsageStorageBinding = gputypes.TextureUsageStorageBinding TextureUsageRenderAttachment = gputypes.TextureUsageRenderAttachment )
Texture usage constants
const ( TextureDimension1D = gputypes.TextureDimension1D TextureDimension2D = gputypes.TextureDimension2D TextureDimension3D = gputypes.TextureDimension3D )
Texture dimension constants
const ( TextureFormatRGBA8Unorm = gputypes.TextureFormatRGBA8Unorm TextureFormatRGBA8UnormSrgb = gputypes.TextureFormatRGBA8UnormSrgb TextureFormatBGRA8Unorm = gputypes.TextureFormatBGRA8Unorm TextureFormatBGRA8UnormSrgb = gputypes.TextureFormatBGRA8UnormSrgb TextureFormatDepth24Plus = gputypes.TextureFormatDepth24Plus TextureFormatDepth32Float = gputypes.TextureFormatDepth32Float )
Commonly used texture format constants
const ( ShaderStageVertex = gputypes.ShaderStageVertex ShaderStageFragment = gputypes.ShaderStageFragment ShaderStageCompute = gputypes.ShaderStageCompute )
Shader stage constants
const ( PresentModeImmediate = gputypes.PresentModeImmediate PresentModeMailbox = gputypes.PresentModeMailbox PresentModeFifo = gputypes.PresentModeFifo PresentModeFifoRelaxed = gputypes.PresentModeFifoRelaxed )
Present mode constants
const ( PowerPreferenceNone = gputypes.PowerPreferenceNone PowerPreferenceLowPower = gputypes.PowerPreferenceLowPower PowerPreferenceHighPerformance = gputypes.PowerPreferenceHighPerformance )
Power preference constants
const MaxBindGroups = 8
MaxBindGroups is the HAL hard cap on bind groups (wgpu-hal MAX_BIND_GROUPS = 8). Devices may support up to 8, but only MinBindGroups (4) is guaranteed.
const MinBindGroups = 4
MinBindGroups is the minimum guaranteed number of bind groups per WebGPU spec. All compliant devices support at least 4 bind groups. Portable code should use no more than MinBindGroups.
Variables ¶
var ( ErrDeviceLost = hal.ErrDeviceLost ErrOutOfMemory = hal.ErrDeviceOutOfMemory ErrSurfaceLost = hal.ErrSurfaceLost ErrSurfaceOutdated = hal.ErrSurfaceOutdated ErrTimeout = hal.ErrTimeout )
Sentinel errors re-exported from HAL.
var ( // ErrReleased is returned when operating on a released resource. ErrReleased = errors.New("wgpu: resource already released") // ErrNoAdapters is returned when no GPU adapters are found. ErrNoAdapters = errors.New("wgpu: no GPU adapters available") // ErrNoBackends is returned when no backends are registered. ErrNoBackends = errors.New("wgpu: no backends registered (import a backend package)") )
Public API sentinel errors.
var ( // ErrDrawMissingPipeline is returned when Draw/DrawIndexed/DrawIndirect is // called before SetPipeline on a render pass encoder. ErrDrawMissingPipeline = errors.New("wgpu: draw called without SetPipeline") // ErrDrawMissingBindGroup is returned when a draw command is issued but not // all bind groups required by the current pipeline have been set. ErrDrawMissingBindGroup = errors.New("wgpu: draw called with missing bind group") // ErrDrawIncompatibleBindGroup is returned when a draw command is issued but // the bind group set at a slot has an incompatible layout with the pipeline. ErrDrawIncompatibleBindGroup = errors.New("wgpu: draw called with incompatible bind group layout") // ErrDrawMissingVertexBuffer is returned when a draw command is issued but // fewer vertex buffers have been set than the pipeline requires. ErrDrawMissingVertexBuffer = errors.New("wgpu: draw called with insufficient vertex buffers") // ErrDrawMissingIndexBuffer is returned when DrawIndexed or // DrawIndexedIndirect is called before SetIndexBuffer. ErrDrawMissingIndexBuffer = errors.New("wgpu: DrawIndexed called without SetIndexBuffer") // ErrDrawMissingBlendConstant is returned when a draw command is issued // but the pipeline uses BlendFactorConstant and SetBlendConstant was not called. ErrDrawMissingBlendConstant = errors.New("wgpu: draw called without SetBlendConstant (pipeline uses constant blend factor)") // ErrDrawLateBufferTooSmall is returned when a buffer bound via SetBindGroup // is smaller than the shader-required minimum for a binding whose layout // has MinBindingSize == 0. ErrDrawLateBufferTooSmall = errors.New("wgpu: bound buffer smaller than shader-required minimum") // ErrDispatchMissingPipeline is returned when Dispatch/DispatchIndirect is // called before SetPipeline on a compute pass encoder. ErrDispatchMissingPipeline = errors.New("wgpu: dispatch called without SetPipeline") // ErrDispatchMissingBindGroup is returned when a dispatch command is issued // but not all bind groups required by the current pipeline have been set. ErrDispatchMissingBindGroup = errors.New("wgpu: dispatch called with missing bind group") // ErrDispatchIncompatibleBindGroup is returned when a dispatch command is // issued but the bind group set at a slot has an incompatible layout. ErrDispatchIncompatibleBindGroup = errors.New("wgpu: dispatch called with incompatible bind group layout") // ErrDispatchLateBufferTooSmall is returned when a buffer bound via // SetBindGroup is smaller than the shader-required minimum for a dispatch. ErrDispatchLateBufferTooSmall = errors.New("wgpu: dispatch: bound buffer smaller than shader-required minimum") // ErrDispatchWorkgroupCountExceeded is returned when Dispatch is called with // workgroup counts exceeding the device limit. ErrDispatchWorkgroupCountExceeded = errors.New("wgpu: dispatch workgroup count exceeds device limit") // ErrDrawIndexFormatMismatch is returned when the index buffer format // does not match the pipeline's StripIndexFormat for strip topologies. // Matches Rust wgpu-core DrawError::UnmatchedIndexFormats (render.rs:576-580). ErrDrawIndexFormatMismatch = errors.New("wgpu: index buffer format does not match pipeline strip index format") // ErrDrawIndirectBufferUsage is returned when DrawIndirect or // DrawIndexedIndirect is called with a buffer that lacks BufferUsageIndirect. // Matches Rust wgpu-core check_usage(BufferUsages::INDIRECT) (render.rs:2763). ErrDrawIndirectBufferUsage = errors.New("wgpu: indirect draw buffer missing INDIRECT usage") // ErrDrawIndirectOffsetAlignment is returned when DrawIndirect or // DrawIndexedIndirect is called with an offset that is not 4-byte aligned. // Matches Rust wgpu-core UnalignedIndirectBufferOffset (render.rs:2766). ErrDrawIndirectOffsetAlignment = errors.New("wgpu: indirect draw buffer offset not 4-byte aligned") // ErrDispatchIndirectBufferUsage is returned when DispatchIndirect is called // with a buffer that lacks BufferUsageIndirect. // Matches Rust wgpu-core check_usage(BufferUsages::INDIRECT) (compute.rs:896). ErrDispatchIndirectBufferUsage = errors.New("wgpu: indirect dispatch buffer missing INDIRECT usage") // ErrDispatchIndirectOffsetAlignment is returned when DispatchIndirect is // called with an offset that is not 4-byte aligned. // Matches Rust wgpu-core UnalignedIndirectBufferOffset (compute.rs:899). ErrDispatchIndirectOffsetAlignment = errors.New("wgpu: indirect dispatch buffer offset not 4-byte aligned") // ErrDrawIndirectBufferOverrun is returned when DrawIndirect or // DrawIndexedIndirect args extend past the end of the buffer. // Matches Rust wgpu-core IndirectBufferOverrun (render.rs:2772-2779). ErrDrawIndirectBufferOverrun = errors.New("wgpu: indirect draw args exceed buffer size") // ErrDispatchIndirectBufferOverrun is returned when DispatchIndirect // args extend past the end of the buffer. // Matches Rust wgpu-core IndirectBufferOverrun (compute.rs:903-909). ErrDispatchIndirectBufferOverrun = errors.New("wgpu: indirect dispatch args exceed buffer size") )
Draw-time validation sentinel errors. These are wrapped with additional context (e.g., method name) and surfaced as deferred errors on Finish(). Use errors.Is() to match programmatically.
Matches Rust wgpu-core DrawError / DispatchError variants (command/render.rs:542-593, command/compute.rs:278-284).
var ( // ErrSubmitBufferDestroyed is returned when a submitted command buffer // references a buffer that has been released/destroyed. // Matches Rust QueueSubmitError::DestroyedResource for buffers. ErrSubmitBufferDestroyed = errors.New("wgpu: Submit: command buffer references destroyed buffer") // ErrSubmitBufferMapped is returned when a submitted command buffer // references a buffer that is currently mapped. Submitting GPU commands // that read/write a mapped buffer is a data race. // Matches Rust QueueSubmitError::BufferStillMapped. ErrSubmitBufferMapped = errors.New("wgpu: Submit: command buffer references mapped buffer") // ErrSubmitTextureDestroyed is returned when a submitted command buffer // references a texture that has been released/destroyed. // Matches Rust QueueSubmitError::DestroyedResource for textures. ErrSubmitTextureDestroyed = errors.New("wgpu: Submit: command buffer references destroyed texture") // ErrSubmitBindGroupDestroyed is returned when a submitted command buffer // references a bind group that has been released/destroyed. // Matches Rust wgpu-core validate_command_buffer bind_group.try_raw() // (device/queue.rs:1815-1817). ErrSubmitBindGroupDestroyed = errors.New("wgpu: Submit: command buffer references destroyed bind group") // ErrSubmitCommandBufferInvalid is returned when a command buffer has // already been submitted or was never properly finished. // Matches Rust QueueSubmitError::CommandEncoder for invalid command buffers. ErrSubmitCommandBufferInvalid = errors.New("wgpu: Submit: command buffer is invalid (already submitted or encoding error)") )
Queue.Submit validation sentinel errors (VAL-A6). Returned when Submit detects that a command buffer references resources in an invalid state. These match Rust wgpu-core QueueSubmitError variants (device/queue.rs:484-516).
var ( // ErrMapAlreadyPending — a Map or MapAsync was called on a buffer // that already has an in-flight map request. ErrMapAlreadyPending = errors.New("wgpu: buffer map already pending") // ErrMapAlreadyMapped — a Map or MapAsync was called on a buffer // that is already in the Mapped state. ErrMapAlreadyMapped = errors.New("wgpu: buffer is already mapped") // ErrMapNotMapped — Unmap or MappedRange was called on a buffer that // is not currently mapped. ErrMapNotMapped = errors.New("wgpu: buffer is not mapped") // ErrMapRangeOverlap — MappedRange was called with a range that // overlaps a previously-returned MappedRange that has not yet been // invalidated by Unmap. ErrMapRangeOverlap = errors.New("wgpu: mapped range overlaps existing") // ErrMapRangeDetached — MappedRange.Bytes was called after the owning // buffer was unmapped or destroyed, leaving the range invalid. ErrMapRangeDetached = errors.New("wgpu: mapped range detached (buffer unmapped)") // ErrMapAlignment — the requested offset is not a multiple of 8 // bytes, or the requested size is not a multiple of 4 bytes, in // violation of WebGPU spec MAP_ALIGNMENT / copy alignment. ErrMapAlignment = errors.New("wgpu: map offset/size not aligned") // ErrMapCanceled — a pending map was canceled by a concurrent // Unmap, Destroy, or context cancellation before the GPU resolved it. // Analogous to WebGPU AbortError. ErrMapCanceled = errors.New("wgpu: map canceled") // ErrBufferDestroyed — Buffer.Destroy was called while the map was // pending, or a Map call targeted an already-destroyed buffer. ErrBufferDestroyed = errors.New("wgpu: buffer destroyed") // ErrMapDeviceLost — the device was lost while the map was pending. ErrMapDeviceLost = errors.New("wgpu: device lost during map") // ErrMapInvalidMode — Map or MapAsync was called on a buffer that // was not created with the matching MAP_READ or MAP_WRITE usage. ErrMapInvalidMode = errors.New("wgpu: buffer not created with required MAP_READ/MAP_WRITE usage") // ErrMapRangeOverflow — the requested offset + size exceeds the // buffer size. ErrMapRangeOverflow = errors.New("wgpu: map range exceeds buffer size") )
Typed buffer mapping errors. Callers can use errors.Is to branch on specific failure modes without matching strings.
var ( DefaultLimits = gputypes.DefaultLimits DefaultInstanceDescriptor = gputypes.DefaultInstanceDescriptor )
Default functions (re-exported for convenience)
var ErrInvalidSurfaceTarget = errors.New("wgpu: invalid surface target")
ErrInvalidSurfaceTarget is returned when a surface target is empty or has missing platform handles.
var ErrUnsupportedSurfaceTarget = errors.New("wgpu: unsupported surface target")
ErrUnsupportedSurfaceTarget is returned when the selected implementation cannot create a surface for the supplied platform target kind.
Functions ¶
func SetLogger ¶
SetLogger configures the logger for the entire wgpu stack (public API, core validation layer, and HAL backends: Vulkan, Metal, DX12, GLES).
By default, wgpu produces no log output. Call SetLogger to enable logging for deep debugging across the full GPU pipeline.
SetLogger is safe for concurrent use. Pass nil to disable logging (restore default silent behavior).
Types ¶
type Adapter ¶
type Adapter struct {
// contains filtered or unexported fields
}
Adapter represents a physical GPU.
func (*Adapter) DownlevelCapabilities ¶
func (a *Adapter) DownlevelCapabilities() gputypes.DownlevelCapabilities
DownlevelCapabilities returns backend capability flags for downlevel adapters. Matches Rust wgpu Adapter::get_downlevel_capabilities() (adapter.rs:174).
func (*Adapter) GetSurfaceCapabilities ¶
func (a *Adapter) GetSurfaceCapabilities(surface *Surface) *SurfaceCapabilities
GetSurfaceCapabilities returns the capabilities of a surface for this adapter. Returns nil if the adapter has no HAL (core-only path) or the surface is nil.
func (*Adapter) RequestDevice ¶
func (a *Adapter) RequestDevice(desc *DeviceDescriptor) (*Device, error)
RequestDevice creates a logical device from this adapter. If desc is nil, default features and limits are used.
type BindGroup ¶
type BindGroup struct {
// contains filtered or unexported fields
}
BindGroup represents bound GPU resources for shader access.
func (*BindGroup) Release ¶
func (g *BindGroup) Release()
Release marks the bind group for destruction. Drops the application's ownership reference via ResourceRef.Drop(). If the bind group is still referenced by in-flight GPU submissions (Clone'd via SetBindGroup), the HAL bind group stays alive until the GPU completes and Triage drops all tracked refs. The onZero callback (set at CreateBindGroup) fires only when the last reference drops, deferring HAL destruction via DestroyQueue.
This matches Rust wgpu's Arc<BindGroup> Drop behavior — deterministic, refcount-driven destruction. ADR-056: unified resource lifecycle.
type BindGroupDescriptor ¶
type BindGroupDescriptor struct {
Label string
Layout *BindGroupLayout
Entries []BindGroupEntry
}
BindGroupDescriptor describes a bind group.
type BindGroupEntry ¶
type BindGroupEntry struct {
Binding uint32
Buffer *Buffer // For buffer bindings
Offset uint64 // Buffer offset
Size uint64 // Buffer binding size (0 = rest of buffer)
Sampler *Sampler // For sampler bindings
TextureView *TextureView // For texture bindings
}
BindGroupEntry describes a single resource binding in a bind group. Exactly one of Buffer, Sampler, or TextureView must be set.
type BindGroupLayout ¶
type BindGroupLayout struct {
// contains filtered or unexported fields
}
BindGroupLayout defines the structure of resource bindings for shaders.
func (*BindGroupLayout) Release ¶
func (l *BindGroupLayout) Release()
Release destroys the bind group layout. Destruction is deferred until the GPU completes any submission that may reference this layout.
A layout GetBindGroupLayout returns from a pipeline created without a Layout belongs to the pipeline and is released with it: Release does nothing to it.
type BindGroupLayoutDescriptor ¶
type BindGroupLayoutDescriptor struct {
Label string
Entries []gputypes.BindGroupLayoutEntry
}
BindGroupLayoutDescriptor describes a bind group layout.
type Buffer ¶
type Buffer struct {
// contains filtered or unexported fields
}
Buffer represents a GPU buffer.
func (*Buffer) Map ¶
Map blocks until a CPU-visible mapping is established for the given byte range, or until ctx is canceled.
The buffer must have been created with BufferUsageMapRead or BufferUsageMapWrite matching mode. offset must be a multiple of 8 and size must be a multiple of 4 (WebGPU MAP_ALIGNMENT).
After Map succeeds, call MappedRange to obtain a byte view and Unmap when finished. The primary usage pattern mirrors database/sql rows:
if err := buf.Map(ctx, wgpu.MapModeRead, 0, size); err != nil {
return err
}
defer buf.Unmap()
rng, _ := buf.MappedRange(0, size)
data := rng.Bytes()
Map drives Device.Poll internally; callers do not need to schedule polling themselves. It waits for the GPU to finish the submission the map waits for, not for work submitted after it, and Submit on other goroutines goes on meanwhile. If you need non-blocking behavior use MapAsync.
If ctx is done before the map resolves, Map cancels the request and returns ctx.Err(), leaving the buffer unmapped.
func (*Buffer) MapAsync ¶
func (b *Buffer) MapAsync(mode MapMode, offset, size uint64) (*MapPending, error)
MapAsync initiates a buffer map without blocking the caller.
Returns a *MapPending handle that resolves once the GPU submission that last wrote to the buffer completes. The caller must periodically drive Device.Poll(PollPoll) (or, more commonly, rely on the auto-poll at the tail of Queue.Submit) to let the mapping resolve.
Validation errors surface synchronously — alignment, usage mismatch, range overflow, already-mapped state, etc. A returned MapPending is always valid; its Status() may resolve as failed later if the buffer is destroyed, the map is canceled or the device is released.
func (*Buffer) MapState ¶
MapState returns the current mapping state of the buffer.
This is a synchronized snapshot — the state may change immediately after return if another goroutine calls Unmap or Destroy, but the value reflects the state at the moment of the call.
func (*Buffer) MappedRange ¶
func (b *Buffer) MappedRange(offset, size uint64) (*MappedRange, error)
MappedRange returns a safe view over the mapped region [offset, offset+size).
The buffer must be in the Mapped state (Map or MapAsync resolved). The returned range overlaps with neither the rest of the buffer nor any previously-returned MappedRange that has not been Unmap'd — WebGPU spec §5.3.4 forbids overlapping getMappedRange calls on the same buffer and we enforce this synchronously.
The returned slice (via MappedRange.Bytes) is invalidated by Unmap.
func (*Buffer) Release ¶
func (b *Buffer) Release()
Release drops the application's ownership reference to the buffer.
If the buffer is still referenced by in-flight GPU submissions (Clone'd via SetBindGroup/SetVertexBuffer/CopyBufferToBuffer), the HAL buffer stays alive until the GPU completes and Phase 2 Triage drops all tracked refs. The onZero callback (set at CreateBuffer) fires only when the last reference drops, HAL-destroying the buffer. This matches Rust wgpu's Arc<Buffer> Drop behavior — deterministic, refcount-driven destruction.
If the buffer was never encoded, refcount goes 1→0 immediately and the HAL buffer is destroyed inline.
func (*Buffer) Unmap ¶
Unmap releases the current mapping and invalidates all outstanding MappedRange handles for this buffer. Safe to call multiple times; a second call returns ErrMapNotMapped.
Unmap also cancels a Pending map (the associated MapPending resolves with ErrMapCancelled).
func (*Buffer) Usage ¶
func (b *Buffer) Usage() gputypes.BufferUsage
Usage returns the buffer's usage flags.
type BufferDescriptor ¶
type BufferDescriptor struct {
Label string
Size uint64
Usage gputypes.BufferUsage
MappedAtCreation bool
}
BufferDescriptor describes buffer creation parameters.
type BufferTextureCopy ¶
type BufferTextureCopy struct {
BufferLayout ImageDataLayout
TextureBase ImageCopyTexture
Size Extent3D
}
BufferTextureCopy defines a buffer-texture copy region.
type CommandBuffer ¶
type CommandBuffer struct {
// contains filtered or unexported fields
}
CommandBuffer holds recorded GPU commands ready for submission. Created by CommandEncoder.Finish().
It is submitted once. After Submit or Release it is spent and a Submit of it fails, but don't keep it: the memory behind it is reused for the command buffer of a later encoder.
func (*CommandBuffer) Release ¶
func (cb *CommandBuffer) Release()
Release releases a CommandBuffer that will NOT be submitted to the GPU. This returns the HAL encoder to the device pool and drops tracked resource refs.
In normal flow, Submit() takes ownership of the encoder and handles recycling after GPU completion. Release() is for error paths and canceled operations where the CommandBuffer is discarded without submitting.
Matches Rust wgpu-core InnerCommandEncoder::Drop (command/mod.rs:726-738) which always calls reset_all + release_encoder regardless of whether the command buffer was submitted.
A CommandBuffer MUST be either Submit()'d or Release()'d. Failing to do either leaks the HAL encoder (DX12 ~64KB allocator, Vulkan VkCommandPool).
type CommandEncoder ¶
type CommandEncoder struct {
// contains filtered or unexported fields
}
CommandEncoder records GPU commands for later submission.
A command encoder is single-use. After calling Finish(), the encoder cannot be used again. Call Device.CreateCommandEncoder() to create a new one.
NOT thread-safe - do not use from multiple goroutines.
func (*CommandEncoder) BeginComputePass ¶
func (e *CommandEncoder) BeginComputePass(desc *ComputePassDescriptor) (*ComputePassEncoder, error)
BeginComputePass begins a compute pass. The returned ComputePassEncoder records dispatch commands. Call ComputePassEncoder.End() when done.
func (*CommandEncoder) BeginRenderPass ¶
func (e *CommandEncoder) BeginRenderPass(desc *RenderPassDescriptor) (*RenderPassEncoder, error)
BeginRenderPass begins a render pass. The returned RenderPassEncoder records draw commands. Call RenderPassEncoder.End() when done.
func (*CommandEncoder) ClearBuffer ¶
func (e *CommandEncoder) ClearBuffer(buffer *Buffer, offset, size uint64)
ClearBuffer zeroes size bytes of buffer from offset on, or the rest of the buffer from offset on when size is 0, as clearBuffer without a size does. The buffer needs CopyDst, and offset and size are multiples of 4. WebGPU spec: GPUCommandEncoder.clearBuffer.
func (*CommandEncoder) CopyBufferToBuffer ¶
func (e *CommandEncoder) CopyBufferToBuffer(src *Buffer, srcOffset uint64, dst *Buffer, dstOffset uint64, size uint64)
CopyBufferToBuffer copies data between buffers.
func (*CommandEncoder) CopyBufferToTexture ¶
func (e *CommandEncoder) CopyBufferToTexture(src *Buffer, dst *Texture, regions []BufferTextureCopy)
func (*CommandEncoder) CopyTextureToBuffer ¶
func (e *CommandEncoder) CopyTextureToBuffer(src *Texture, dst *Buffer, regions []BufferTextureCopy)
CopyTextureToBuffer copies data from a texture to a buffer. This is used for GPU-to-CPU readback of rendered content.
func (*CommandEncoder) CopyTextureToTexture ¶
func (e *CommandEncoder) CopyTextureToTexture(src, dst *Texture, regions []TextureCopy)
CopyTextureToTexture copies data between textures using DMA hardware copy. WebGPU spec: GPUCommandEncoder.copyTextureToTexture()
func (*CommandEncoder) DiscardEncoding ¶
func (e *CommandEncoder) DiscardEncoding()
DiscardEncoding discards the encoder without producing a command buffer. Use this to abandon an in-progress encoding when an error occurs. If the encoder was acquired from the pool, it is returned for reuse.
func (*CommandEncoder) Finish ¶
func (e *CommandEncoder) Finish() (_ *CommandBuffer, err error)
Finish completes command recording and returns a CommandBuffer. After calling Finish(), the encoder cannot be used again.
The HAL encoder ownership transfers from the CommandEncoder to the CommandBuffer. After GPU completion, Submit() schedules the encoder to be reset via ResetAll and returned to the Device's encoder pool.
func (*CommandEncoder) ResolveQuerySet ¶
func (e *CommandEncoder) ResolveQuerySet(querySet *QuerySet, firstQuery, queryCount uint32, dst *Buffer, dstOffset uint64)
ResolveQuerySet copies query results into a buffer.
func (*CommandEncoder) TransitionTextures ¶
func (e *CommandEncoder) TransitionTextures(barriers []TextureBarrier)
TransitionTextures records explicit texture barriers.
Copy commands and render passes already transition their textures from the state left by earlier commands of the same encoder, so explicit barriers are only needed for states the encoder cannot see. Each explicit barrier also updates the encoder's tracker: later commands transition from the barrier's NewUsage instead of repeating it. On Metal, GLES, and software backends the barrier itself is a no-op.
type CommandEncoderDescriptor ¶
type CommandEncoderDescriptor struct {
Label string
}
CommandEncoderDescriptor describes command encoder creation.
type ComputePassDescriptor ¶
type ComputePassDescriptor struct {
Label string
TimestampWrites *ComputePassTimestampWrites
}
ComputePassDescriptor describes a compute pass.
type ComputePassEncoder ¶
type ComputePassEncoder struct {
// contains filtered or unexported fields
}
ComputePassEncoder records compute dispatch commands.
Created by CommandEncoder.BeginComputePass(). Must be ended with End() before the CommandEncoder can be finished.
NOT thread-safe.
func (*ComputePassEncoder) Dispatch ¶
func (p *ComputePassEncoder) Dispatch(x, y, z uint32)
Dispatch dispatches compute work.
func (*ComputePassEncoder) DispatchIndirect ¶
func (p *ComputePassEncoder) DispatchIndirect(buffer *Buffer, offset uint64)
DispatchIndirect dispatches compute work with GPU-generated parameters.
When indirect dispatch validation is available (created at device init), a pre-dispatch validation shader checks workgroup counts against maxComputeWorkgroupsPerDimension and clamps to (0,0,0) if exceeded. This prevents GPU hangs/TDR from invalid indirect buffers.
Matches Rust wgpu-core compute.rs:878-1074 (dispatch_indirect).
func (*ComputePassEncoder) End ¶
func (p *ComputePassEncoder) End() error
End ends the compute pass.
func (*ComputePassEncoder) SetBindGroup ¶
func (p *ComputePassEncoder) SetBindGroup(index uint32, group *BindGroup, offsets []uint32)
SetBindGroup sets a bind group for the given index. The backend gets it once the pipeline's layout takes it at index.
func (*ComputePassEncoder) SetPipeline ¶
func (p *ComputePassEncoder) SetPipeline(pipeline *ComputePipeline)
SetPipeline sets the active compute pipeline.
type ComputePassTimestampWrites ¶
type ComputePassTimestampWrites = RenderPassTimestampWrites
ComputePassTimestampWrites describes timestamp query writes at compute pass boundaries, as a render pass's.
type ComputePipeline ¶
type ComputePipeline struct {
// contains filtered or unexported fields
}
ComputePipeline represents a configured compute pipeline.
func (*ComputePipeline) GetBindGroupLayout ¶
func (p *ComputePipeline) GetBindGroupLayout(index uint32) *BindGroupLayout
GetBindGroupLayout returns the bind group layout at index of the pipeline's layout, or nil past its last group. For a pipeline created without a Layout these are the layouts derived from its shader, to make its bind groups with. They belong to the pipeline and are released with it.
func (*ComputePipeline) Release ¶
func (p *ComputePipeline) Release()
Release drops the application's ownership reference to the compute pipeline.
If the pipeline is still referenced by in-flight GPU submissions (Clone'd via SetPipeline), the HAL pipeline stays alive until the GPU completes and Triage drops all tracked refs. The onZero callback (set at CreateComputePipeline) fires only when the last reference drops. ADR-056: unified resource lifecycle.
type ComputePipelineDescriptor ¶
type ComputePipelineDescriptor struct {
Label string
Layout *PipelineLayout
Module *ShaderModule
EntryPoint string
// Constants are pipeline-overridable constants (WebGPU spec).
// Keys are constant identifiers defined in the shader, values are float64 overrides.
// Nil or empty means no overrides are applied.
//
// Matches Rust wgpu PipelineConstants (wgpu-types). Each backend applies these
// during shader compilation via naga's override processing.
Constants map[string]float64
// ZeroInitializeWorkgroupMemory controls whether workgroup-scoped shared memory
// is zero-initialized before compute shader execution (WebGPU spec default: true).
//
// When nil (zero value for *bool), defaults to true per WebGPU spec.
// Set to false only for cross-platform applications that do not rely on
// zero-initialized workgroup memory and want to avoid the overhead.
//
// Matches Rust wgpu ProgrammableStage.zero_initialize_workgroup_memory.
ZeroInitializeWorkgroupMemory *bool
}
ComputePipelineDescriptor describes a compute pipeline.
type DepthStencilState ¶
type DepthStencilState struct {
Format gputypes.TextureFormat
DepthWriteEnabled bool
DepthCompare gputypes.CompareFunction
StencilFront StencilFaceState
StencilBack StencilFaceState
StencilReadMask uint32
StencilWriteMask uint32
DepthBias int32
DepthBiasSlopeScale float32
DepthBiasClamp float32
}
DepthStencilState describes depth and stencil testing configuration.
type Device ¶
type Device struct {
// contains filtered or unexported fields
}
Device represents a logical GPU device. It is the main interface for creating GPU resources.
Device methods are safe for concurrent use, except Release() which must not be called concurrently with other methods.
func NewDeviceFromHAL ¶
func NewDeviceFromHAL( halDevice hal.Device, halQueue hal.Queue, features gputypes.Features, limits gputypes.Limits, label string, ) (*Device, error)
NewDeviceFromHAL creates a Device wrapping existing HAL device and queue objects. This constructor is used by backends that manage their own HAL lifecycle (e.g., the Rust FFI backend via wgpu-native) and need to expose their HAL objects through the wgpu public API.
Ownership of halDevice and halQueue is transferred to the returned Device. The caller must not destroy them directly after this call.
func (*Device) CreateBindGroup ¶
func (d *Device) CreateBindGroup(desc *BindGroupDescriptor) (_ *BindGroup, err error)
CreateBindGroup creates a bind group.
func (*Device) CreateBindGroupLayout ¶
func (d *Device) CreateBindGroupLayout(desc *BindGroupLayoutDescriptor) (_ *BindGroupLayout, err error)
CreateBindGroupLayout creates a bind group layout.
func (*Device) CreateBuffer ¶
func (d *Device) CreateBuffer(desc *BufferDescriptor) (_ *Buffer, err error)
CreateBuffer creates a GPU buffer.
func (*Device) CreateCommandEncoder ¶
func (d *Device) CreateCommandEncoder(desc *CommandEncoderDescriptor) (_ *CommandEncoder, err error)
CreateCommandEncoder creates a command encoder for recording GPU commands.
When a device-level encoder pool is available (BUG-DX12-004), the HAL encoder is acquired from the pool instead of creating a new one. This avoids allocating expensive GPU resources (DX12 ID3D12CommandAllocator ~64KB, Vulkan VkCommandPool) on every frame. After GPU completion, the encoder is reset and returned to the pool for reuse. Matches Rust wgpu-core's CommandAllocator pattern (allocator.rs).
func (*Device) CreateComputePipeline ¶
func (d *Device) CreateComputePipeline(desc *ComputePipelineDescriptor) (_ *ComputePipeline, err error)
CreateComputePipeline creates a compute pipeline.
func (*Device) CreateFence ¶
CreateFence creates a GPU synchronization fence. Fences are primarily used by the HAL internally for synchronization. Most callers should use Queue.Submit + Queue.Poll instead.
func (*Device) CreatePipelineLayout ¶
func (d *Device) CreatePipelineLayout(desc *PipelineLayoutDescriptor) (_ *PipelineLayout, err error)
CreatePipelineLayout creates a pipeline layout.
func (*Device) CreateQuerySet ¶
func (d *Device) CreateQuerySet(desc *QuerySetDescriptor) (_ *QuerySet, err error)
CreateQuerySet creates a query set for occlusion or timestamp queries.
func (*Device) CreateRenderBundleEncoder ¶
func (d *Device) CreateRenderBundleEncoder(desc *RenderBundleEncoderDescriptor) (_ *RenderBundleEncoder, err error)
CreateRenderBundleEncoder creates an encoder for reusable render commands.
func (*Device) CreateRenderPipeline ¶
func (d *Device) CreateRenderPipeline(desc *RenderPipelineDescriptor) (_ *RenderPipeline, err error)
CreateRenderPipeline creates a render pipeline.
func (*Device) CreateSampler ¶
func (d *Device) CreateSampler(desc *SamplerDescriptor) (_ *Sampler, err error)
CreateSampler creates a texture sampler.
func (*Device) CreateShaderModule ¶
func (d *Device) CreateShaderModule(desc *ShaderModuleDescriptor) (_ *ShaderModule, err error)
CreateShaderModule creates a shader module.
func (*Device) CreateTexture ¶
func (d *Device) CreateTexture(desc *TextureDescriptor) (_ *Texture, err error)
CreateTexture creates a GPU texture.
func (*Device) CreateTextureView ¶
func (d *Device) CreateTextureView(texture *Texture, desc *TextureViewDescriptor) (_ *TextureView, err error)
CreateTextureView creates a view into a texture.
func (*Device) DestroyFence
deprecated
func (*Device) FreeCommandBuffer ¶
func (d *Device) FreeCommandBuffer(cb *CommandBuffer)
FreeCommandBuffer returns a command buffer to the command pool. This must be called after the GPU has finished using the command buffer. The command buffer handle becomes invalid after this call. For multi-CB encoders, all accumulated HAL command buffers are freed.
func (*Device) GetFenceStatus ¶
GetFenceStatus returns true if the fence is signaled (non-blocking). This is used for polling completion without blocking.
func (*Device) HalDevice ¶
HalDevice returns the underlying HAL device for advanced use cases. This enables interop with code that needs direct HAL access (e.g., gg GPU accelerator, DeviceProvider interfaces).
Returns nil if the device has been released or has no HAL backend.
func (*Device) Poll ¶
Poll drives the per-device pending-map triage loop.
PollPoll drains any buffer mappings whose associated GPU submissions have already completed and returns immediately. This is the fast path for game loops and is called automatically from Queue.Submit, so beginner code paths never need to call Poll explicitly.
PollWait blocks until the GPU has finished every submission made before the call, then drains all buckets. It waits for the last of them, not for work submitted meanwhile, and does not hold up Submit. It is appropriate for shutdown drains and short scripts that do not run a render loop.
The return value reports whether Poll observed any in-flight maps — tests use it to assert that Submit-driven auto-polling drained everything without needing an explicit Poll call. After Release, Poll does nothing and returns false.
func (*Device) PopErrorScope ¶
PopErrorScope pops the most recently pushed error scope. Returns the captured error, or nil if no error occurred. Panics if no error scope is pushed.
func (*Device) PushErrorScope ¶
func (d *Device) PushErrorScope(filter ErrorFilter)
PushErrorScope pushes a new error scope onto the device's error scope stack.
func (*Device) Release ¶
func (d *Device) Release()
Release releases the device and all associated resources. Deferred resource destructions are flushed before the device is destroyed. Shutdown order:
- Retire active surface acquisitions
- WaitIdle and maintain completed work
- Discard unsubmitted queue writes
- Triage + FlushAll — deferred callbacks fire (encoders return to pool)
- Destroy encoder pool (HAL device still alive)
- Destroy core + HAL device
WaitIdle is required because FlushAll calls Triage(PollCompleted()), but PollCompleted may return a stale index if GPU hasn't finished. Without WaitIdle, deferred encoder recycling callbacks don't fire, and pool.destroy() destroys encoders whose VkCommandPool is then double-freed by hal.Device.Destroy() → vkDestroyCommandPool crash.
Rust avoids this via Arc ownership + maintain loop. In Go we must be explicit: WaitIdle ensures PollCompleted returns final index.
func (*Device) ResetFence ¶
ResetFence resets a fence to the unsignaled state. The fence must not be in use by the GPU.
func (*Device) SetUncapturedErrorHandler ¶
SetUncapturedErrorHandler sets the function that gets every GPU error no error scope captured: validation, out-of-memory and internal errors, each with its Type and message. A newer call replaces the older handler, and nil removes it and restores the default handling of uncaptured errors.
In a native build the handler runs on the goroutine whose call made the error, before that call returns the error as well, so calls on several goroutines can run it at the same time. Without a handler an uncaptured error goes to the logger SetLogger sets, at debug level.
func (*Device) WaitForFence ¶
WaitForFence waits for a fence to reach the specified value. Returns true if the fence reached the value, false if timeout expired.
type DeviceDescriptor ¶
type DeviceDescriptor struct {
Label string
RequiredFeatures gputypes.Features
RequiredLimits gputypes.Limits
}
DeviceDescriptor configures device creation.
type ErrorFilter ¶
type ErrorFilter = core.ErrorFilter
type ExternalBuffer ¶
ExternalBuffer is a buffer of the device made outside gowgpu that holds a picture another API draws, such as OpenGL through memory it shares, which a timeline orders as it does an ExternalImage: a VkBuffer and a timeline VkSemaphore on Vulkan, an ID3D12Resource and an ID3D12Fence on Direct3D 12, where BytesPerRow must be a multiple of 256, an id<MTLBuffer> and an id<MTLSharedEvent> on Metal.
type ExternalImage ¶
ExternalImage is a multi-planar image of the device made outside gowgpu, such as a video decoder's, which a timeline orders: its users wait for it to reach Value before they touch the image, and signal Value+1 when done. On Vulkan it is a VkImage in the VkImageLayout Layout, ordered by a timeline VkSemaphore; on Direct3D 12 an ID3D12Resource in the D3D12_RESOURCE_STATES Layout, COMMON, layer Slice of it when it is an array, and an ID3D12Fence; on Metal an IOSurfaceRef, such as a VideoToolbox CVPixelBuffer's, and an id<MTLSharedEvent>, Layout and Slice unused.
type Fence ¶
type Fence struct {
// contains filtered or unexported fields
}
Fence is a GPU synchronization primitive. Fences allow CPU-GPU synchronization by signaling when submitted work completes.
Fences are created via Device.CreateFence and should be released via Release() when no longer needed.
type FragmentState ¶
type FragmentState struct {
Module *ShaderModule
EntryPoint string
Targets []gputypes.ColorTargetState
}
FragmentState describes the fragment shader stage.
type ImageCopyTexture ¶
type ImageCopyTexture struct {
Texture *Texture
MipLevel uint32
Origin Origin3D
Aspect gputypes.TextureAspect
}
ImageCopyTexture describes a texture subresource and origin for write operations.
type ImageDataLayout ¶
ImageDataLayout describes the layout of image data in a buffer.
type Instance ¶
type Instance struct {
// contains filtered or unexported fields
}
Instance is the entry point for GPU operations.
Instance methods are safe for concurrent use, except Release() which must not be called concurrently with other methods.
func CreateInstance ¶
func CreateInstance(desc *InstanceDescriptor) (*Instance, error)
CreateInstance creates a new GPU instance. If desc is nil, all available backends are used.
func (*Instance) CreateSurface ¶
CreateSurface creates a rendering surface from legacy platform-specific handles. New code should prefer CreateSurfaceFromTarget or CreateSurfaceUnsafe so the target kind and ownership contract are explicit. displayHandle and windowHandle are platform-specific:
- Windows: displayHandle=0, windowHandle=HWND
- macOS: displayHandle=0, windowHandle=CAMetalLayer*
- Linux/X11: displayHandle=Display*, windowHandle=Window
- Linux/Wayland: displayHandle=wl_display*, windowHandle=wl_surface*
- Android: displayHandle ignored, windowHandle=ANativeWindow*
func (*Instance) CreateSurfaceFromTarget ¶
func (i *Instance) CreateSurfaceFromTarget(target SurfaceTarget) (*Surface, error)
CreateSurfaceFromTarget samples a provider once and retains it until the surface is released. The provider's native objects must remain valid for the same lifetime.
func (*Instance) CreateSurfaceUnsafe ¶
func (i *Instance) CreateSurfaceUnsafe(target SurfaceTargetUnsafe) (*Surface, error)
CreateSurfaceUnsafe creates a surface from raw platform handles without retaining an ownership source. Every referenced native object must remain valid until the returned Surface is released.
func (*Instance) Release ¶
func (i *Instance) Release()
Release releases the instance and all associated resources.
func (*Instance) RequestAdapter ¶
func (i *Instance) RequestAdapter(opts *RequestAdapterOptions) (*Adapter, error)
RequestAdapter requests a GPU adapter matching the options. If opts is nil, the best available adapter is returned.
When opts.CompatibleSurface is set, backends that require a surface for adapter enumeration (GLES/OpenGL) will perform deferred enumeration using the surface's GL context. This follows the WebGPU spec pattern where requestAdapter accepts a compatible surface hint.
type InstanceDescriptor ¶
type InstanceDescriptor struct {
Backends gputypes.Backends
// Flags controls instance features like debug layers and validation.
// Use gputypes.InstanceFlagsDebug to enable GPU debug layer.
Flags gputypes.InstanceFlags
}
InstanceDescriptor configures instance creation.
type LateBufferBindingInfo ¶
type LateBufferBindingInfo struct {
// BindingIndex is the binding number from the layout entry.
BindingIndex uint32
// Size is the actual buffer binding size at bind group creation time.
Size uint64
}
LateBufferBindingInfo records the actual buffer binding size for a layout entry with MinBindingSize == 0. At draw/dispatch time, these sizes are compared against the shader-required minimums stored on the pipeline.
Matches Rust wgpu-core's BindGroupLateBufferBindingInfo (binding_model.rs:1167-1173).
type LateSizedBufferGroup ¶
type LateSizedBufferGroup struct {
ShaderSizes []uint64
}
LateSizedBufferGroup holds the shader-required minimum buffer sizes for bind group entries whose layout specifies MinBindingSize == 0. These sizes are validated at draw/dispatch time against the actual bound buffer sizes.
The order of ShaderSizes matches the order of buffer entries with MinBindingSize == 0 in the corresponding BindGroupLayout, matching Rust wgpu-core's pipeline::LateSizedBufferGroup.
type MapMode ¶
type MapMode uint32
MapMode selects the type of access requested for a buffer mapping. Values match WebGPU spec §5.3.2 GPUMapMode.
type MapPending ¶
type MapPending struct {
// contains filtered or unexported fields
}
MapPending is a zero-allocation handle to an in-flight Buffer.MapAsync.
It is allocated from a sync.Pool and must be released to the pool by calling either Wait, Status (until ready=true), or Release — failing to release simply wastes a pool entry until the next GC, but does not leak memory. The handle becomes invalid once the underlying map has resolved; subsequent Status/Wait calls are idempotent and return the cached result.
MapPending is not safe to share between goroutines without external synchronization; the typical pattern is "create on one goroutine, wait on another".
func (*MapPending) Release ¶
func (p *MapPending) Release()
Release returns the MapPending to the pool without waiting. Calling this while the map is still in flight is allowed; the pending map continues to resolve inside Device.Poll but its completion is not observable through this handle anymore.
func (*MapPending) Status ¶
func (p *MapPending) Status() (ready bool, err error)
Status reports the current state of the pending map without blocking.
- (true, nil) — mapping is ready; call Buffer.MappedRange.
- (false, nil) — still pending; caller should continue work and call Device.Poll(PollPoll) in a later tick.
- (true, err) — mapping failed; the buffer is back in the Unmapped state and err describes why.
After Status returns ready=true the MapPending is automatically returned to the pool; subsequent calls are safe but always return the cached (true, err) pair.
func (*MapPending) Wait ¶
func (p *MapPending) Wait(ctx context.Context) error
Wait blocks until the pending map resolves or ctx is canceled.
If ctx is canceled before the GPU resolves the map, Wait returns ctx.Err() and the mapping remains Pending — the caller should normally follow up with Buffer.Unmap to cancel it, or retry Wait later.
type MapState ¶
type MapState uint8
MapState reports the current mapping state of a buffer. Matches WebGPU spec §5.3.3 GPUBufferMapState plus the Destroyed terminal state used internally to guard against use-after-destroy.
const ( // MapStateUnmapped indicates the buffer is not currently mapped. MapStateUnmapped MapState = iota // MapStatePending indicates the buffer has a Map or MapAsync in // progress but the GPU has not yet resolved the underlying fence. MapStatePending // MapStateMapped indicates the buffer is CPU-accessible via // MappedRange; Unmap returns it to Unmapped. MapStateMapped // MapStateDestroyed indicates Buffer.Destroy has been called and the // buffer can never be mapped again. Terminal state. MapStateDestroyed )
type MappedRange ¶
type MappedRange struct {
// contains filtered or unexported fields
}
MappedRange is a safe view over a region of a mapped GPU buffer.
MappedRange replaces raw []byte return from the legacy Queue.ReadBuffer API. It is invalidated atomically on Buffer.Unmap via a per-buffer generation counter — calling Bytes() on a detached range returns nil rather than exposing freed memory, mitigating the UAF pattern that the WebGPU CVE history has accumulated (see ADR §Safety #4).
Typical usage:
if err := buf.Map(ctx, wgpu.MapModeRead, 0, size); err != nil {
return err
}
defer buf.Unmap()
rng, err := buf.MappedRange(0, size)
if err != nil { return err }
data := rng.Bytes() // valid until buf.Unmap()
A single MappedRange is not thread-safe to share between goroutines without external synchronization; typical use is a single owner that copies data out before Unmap.
MappedRange instances are pooled via sync.Pool for zero-allocation steady-state use. Callers that care about allocation counts should call Release() after consuming Bytes().
func (*MappedRange) Bytes ¶
func (m *MappedRange) Bytes() []byte
Bytes returns the underlying byte slice for the mapped range.
The slice points into the buffer's mapping and is valid until the owning buffer is unmapped or released; after Unmap the generation counter advances and Bytes() returns nil. Callers should NOT use the returned slice past Unmap or Release.
Bytes() is safe to call concurrently with itself but not with Unmap on the same buffer — that is the caller's responsibility to coordinate.
func (*MappedRange) BytesMut ¶
func (m *MappedRange) BytesMut() []byte
BytesMut returns a mutable byte slice for writing into the mapped region. On native backend, this returns the same underlying data as Bytes() since the mapped range is already writable through the direct mapping.
func (*MappedRange) Flush ¶
func (m *MappedRange) Flush() error
Flush writes the cached data back. On native backend, data is written through the direct pointer, so this is a no-op.
func (*MappedRange) Len ¶
func (m *MappedRange) Len() int
Len returns the size of the mapped range in bytes.
func (*MappedRange) Offset ¶
func (m *MappedRange) Offset() uint64
Offset returns the byte offset of the mapped range within its buffer.
func (*MappedRange) Release ¶
func (m *MappedRange) Release()
Release returns the MappedRange to the pool. Calling this is optional — the pool simply fills back up on the next GC cycle — but keeping MappedRange calls zero-alloc in the primary Map path requires the caller to Release after the bytes have been consumed.
After Release the MappedRange is invalid; calling Bytes() returns nil.
type PipelineLayout ¶
type PipelineLayout struct {
// contains filtered or unexported fields
}
PipelineLayout defines the bind group layout arrangement for a pipeline.
func (*PipelineLayout) Release ¶
func (l *PipelineLayout) Release()
Release drops the application's reference to the pipeline layout. The HAL layout stays while a pipeline made with it exists, and after the last of them it is destroyed once the GPU completes the submissions that may reference it.
type PipelineLayoutDescriptor ¶
type PipelineLayoutDescriptor struct {
Label string
BindGroupLayouts []*BindGroupLayout
}
PipelineLayoutDescriptor describes a pipeline layout.
type PollType ¶
type PollType uint8
PollType selects the blocking behavior of Device.Poll.
const ( // PollPoll drains any already-completed submissions and returns // immediately without blocking on the GPU. This is the fast path // for game loops that call Poll every frame. PollPoll PollType = iota // PollWait blocks until every submission currently known to the // device has completed, then drains. Used for shutdown drains. PollWait )
type QuerySet ¶
type QuerySet struct {
// contains filtered or unexported fields
}
QuerySet represents a set of GPU queries (occlusion, timestamp, etc.).
type QuerySetDescriptor ¶
QuerySetDescriptor describes query set creation parameters.
type Queue ¶
type Queue struct {
// contains filtered or unexported fields
}
Queue handles command submission and data transfers.
Queue is safe for concurrent use from multiple goroutines. All mutating operations (Submit, WriteBuffer, WriteTexture) are serialized via an internal mutex, matching Rust wgpu-core which uses RwLock::write() on device.fence + device.command_indices during submit (queue.rs:1171-1173).
func (*Queue) CopyExternalBuffer ¶
func (q *Queue) CopyExternalBuffer(src ExternalBuffer, dst *Texture) error
CopyExternalBuffer copies the picture in src into dst, a whole texture made with CopyDst whose rows src holds BytesPerRow apart, top row first. Like CopyExternalPlanes it runs ahead of the next Submit, which waits for src's semaphore to reach src.Value and signals src.Value+1 when done, so src must not be copied again before it. The Vulkan, Direct3D 12 and Metal backends copy external buffers.
func (*Queue) CopyExternalPlanes ¶
func (q *Queue) CopyExternalPlanes(src ExternalImage, dsts ...*Texture) (uint32, error)
CopyExternalPlanes copies the planes of src into dsts, plane i into dsts[i], textures made with CopyDst, as much of the plane as they hold, in a format copies take the plane's texels to: R8 and RG8 for NV12's planes, on Vulkan and Metal RG8 and RGBA8 for P010's. The copy runs ahead of the next Submit, which waits for src's timeline to reach src.Value and has it signal src.Value+1 when done, so src must not be copied again before it. It returns the layout the copy leaves src in. The Vulkan, Direct3D 12 and Metal backends copy external images.
func (*Queue) LastSubmissionIndex ¶
LastSubmissionIndex returns the most recent submission index. Used by resource Release() and onZero callbacks to schedule deferred destruction. Lock-free via atomic — safe to call from onZero callbacks during Triage while Queue.mu is held by Submit. ADR-056 deadlock fix.
func (*Queue) Poll ¶
Poll returns the last completed submission index. Non-blocking. All submissions with index <= the returned value have been completed by the GPU.
func (*Queue) ResolveBuffer ¶
func (q *Queue) ResolveBuffer(idx track.TrackerIndex) hal.Buffer
ResolveBuffer implements core.BarrierResolver over the buffers of the command buffers being submitted.
func (*Queue) ResolveTexture ¶
func (q *Queue) ResolveTexture(idx track.TrackerIndex) hal.Texture
ResolveTexture implements core.BarrierResolver over the textures of the command buffers being submitted.
func (*Queue) SetSwapchainSuppressed ¶
SetSwapchainSuppressed temporarily disables swapchain semaphore binding for subsequent Submit calls. Used for offscreen renders (e.g., RepaintBoundary) that must not consume acquire/present semaphores intended for the compositor submit.
BUG-WGPU-VK-005: When rendering to an offscreen texture before compositing to the swapchain surface, the offscreen submit must not hijack swapchain semaphores. Without suppression, the compositor submit runs without GPU-side synchronization, causing a race condition (flickering).
Call with true before offscreen submits, false after:
queue.SetSwapchainSuppressed(true) defer queue.SetSwapchainSuppressed(false) queue.Submit(offscreenCmds...)
Only meaningful on Vulkan — other backends are no-ops.
func (*Queue) Submit ¶
func (q *Queue) Submit(commandBuffers ...*CommandBuffer) (_ uint64, err error)
Submit submits command buffers for execution. Non-blocking. Returns a submission index that can be used with Poll() to track completion. Command buffers are owned by the caller — free them after Poll confirms completion.
If there are pending WriteBuffer/WriteTexture operations, they are flushed and run ahead of the barriers and the user command buffers in a single HAL submit.
func (*Queue) TimestampPeriod ¶
TimestampPeriod returns how many nanoseconds a tick of a resolved timestamp query is. Vulkan and DX12 resolve ticks, GL nanoseconds.
func (*Queue) WriteBuffer ¶
WriteBuffer writes data to a buffer. If PendingWrites batching is enabled (DX12/Vulkan/Metal), the write is recorded into a shared command encoder and flushed on the next Submit. For GLES/Software backends, the write is performed immediately.
MapWrite buffers (upload heap on DX12, host-visible on Vulkan) are written directly via HAL without staging — GPU copy into upload heap is undefined behavior on DX12 (upload heap is GENERIC_READ, read-only to GPU). See BUG-DX12-003.
Validation (VAL-A1, WebGPU spec §21.1):
- Buffer must not be currently mapped
- Buffer must have CopyDst usage
- offset must be 4-byte aligned
- data size must be 4-byte aligned
- offset + data size must not exceed buffer size
Matches Rust wgpu-core queue.rs:647-672 (validate_write_buffer_impl).
func (*Queue) WriteTexture ¶
func (q *Queue) WriteTexture(dst *ImageCopyTexture, data []byte, layout *ImageDataLayout, size *Extent3D) (err error)
WriteTexture writes data to a texture. If PendingWrites batching is enabled (DX12/Vulkan/Metal), the write is recorded into a shared command encoder and flushed on the next Submit. Resource barriers are computed from the texture's tracked CurrentUsage(). For GLES/Software backends, the write is performed immediately via HAL.
type RenderBundle ¶
type RenderBundle struct {
// contains filtered or unexported fields
}
RenderBundle is a reusable sequence of render commands. A render pass executes it through its own encoder, so its commands are validated and their resources tracked as if the pass had recorded them.
func (*RenderBundle) Release ¶
func (b *RenderBundle) Release()
Release marks the bundle released; render passes skip it after that. It is safe to call Release more than once.
type RenderBundleDescriptor ¶
type RenderBundleDescriptor struct {
Label string
}
RenderBundleDescriptor describes a completed render bundle.
type RenderBundleEncoder ¶
type RenderBundleEncoder struct {
// contains filtered or unexported fields
}
RenderBundleEncoder records reusable render commands.
func (*RenderBundleEncoder) Draw ¶
func (e *RenderBundleEncoder) Draw(args gputypes.DrawArgs)
func (*RenderBundleEncoder) DrawIndexed ¶
func (e *RenderBundleEncoder) DrawIndexed(args gputypes.DrawIndexedArgs)
func (*RenderBundleEncoder) Finish ¶
func (e *RenderBundleEncoder) Finish(desc *RenderBundleDescriptor) (_ *RenderBundle, err error)
Finish completes recording and returns the reusable render bundle.
func (*RenderBundleEncoder) SetBindGroup ¶
func (e *RenderBundleEncoder) SetBindGroup(index uint32, group *BindGroup, offsets []uint32)
func (*RenderBundleEncoder) SetIndexBuffer ¶
func (e *RenderBundleEncoder) SetIndexBuffer(buffer *Buffer, format gputypes.IndexFormat, offset uint64)
func (*RenderBundleEncoder) SetPipeline ¶
func (e *RenderBundleEncoder) SetPipeline(pipeline *RenderPipeline)
func (*RenderBundleEncoder) SetVertexBuffer ¶
func (e *RenderBundleEncoder) SetVertexBuffer(slot uint32, buffer *Buffer, offset uint64)
type RenderBundleEncoderDescriptor ¶
type RenderBundleEncoderDescriptor struct {
Label string
ColorFormats []gputypes.TextureFormat
DepthStencilFormat gputypes.TextureFormat
SampleCount uint32
DepthReadOnly bool
StencilReadOnly bool
}
RenderBundleEncoderDescriptor describes the render pass compatibility of a render bundle recorded by a RenderBundleEncoder.
type RenderPassColorAttachment ¶
type RenderPassColorAttachment struct {
View *TextureView
ResolveTarget *TextureView
LoadOp gputypes.LoadOp
StoreOp gputypes.StoreOp
ClearValue gputypes.Color
}
RenderPassColorAttachment describes a color attachment.
type RenderPassDepthStencilAttachment ¶
type RenderPassDepthStencilAttachment struct {
View *TextureView
DepthLoadOp gputypes.LoadOp
DepthStoreOp gputypes.StoreOp
DepthClearValue float32
DepthReadOnly bool
StencilLoadOp gputypes.LoadOp
StencilStoreOp gputypes.StoreOp
StencilClearValue uint32
StencilReadOnly bool
}
RenderPassDepthStencilAttachment describes a depth/stencil attachment.
type RenderPassDescriptor ¶
type RenderPassDescriptor struct {
Label string
ColorAttachments []RenderPassColorAttachment
DepthStencilAttachment *RenderPassDepthStencilAttachment
TimestampWrites *RenderPassTimestampWrites
}
RenderPassDescriptor describes a render pass.
type RenderPassEncoder ¶
type RenderPassEncoder struct {
// contains filtered or unexported fields
}
RenderPassEncoder records draw commands within a render pass.
Created by CommandEncoder.BeginRenderPass(). Must be ended with End() before the CommandEncoder can be finished.
NOT thread-safe.
func (*RenderPassEncoder) Draw ¶
func (p *RenderPassEncoder) Draw(args gputypes.DrawArgs)
Draw draws primitives. A non-zero FirstInstance needs no feature: WebGPU only gates it for indirect draws (indirect-first-instance), and every registered backend passes it to the native draw.
func (*RenderPassEncoder) DrawIndexed ¶
func (p *RenderPassEncoder) DrawIndexed(args gputypes.DrawIndexedArgs)
DrawIndexed draws indexed primitives.
func (*RenderPassEncoder) DrawIndexedIndirect ¶
func (p *RenderPassEncoder) DrawIndexedIndirect(buffer *Buffer, offset uint64)
DrawIndexedIndirect draws indexed primitives with GPU-generated parameters.
func (*RenderPassEncoder) DrawIndirect ¶
func (p *RenderPassEncoder) DrawIndirect(buffer *Buffer, offset uint64)
DrawIndirect draws primitives with GPU-generated parameters.
func (*RenderPassEncoder) End ¶
func (p *RenderPassEncoder) End() error
End ends the render pass. After this call, the encoder cannot be used again.
func (*RenderPassEncoder) ExecuteBundles ¶
func (p *RenderPassEncoder) ExecuteBundles(bundles ...*RenderBundle)
ExecuteBundles executes reusable render command bundles in this render pass. Each bundle starts without a pipeline, bind groups or vertex and index buffers, and the pass has none of them after the bundles either.
func (*RenderPassEncoder) MultiDrawIndexedIndirect ¶
func (p *RenderPassEncoder) MultiDrawIndexedIndirect(buffer *Buffer, offset uint64, drawCount uint32)
MultiDrawIndexedIndirect draws consecutive indexed primitives with GPU-generated parameters. Each argument record is 20 bytes.
func (*RenderPassEncoder) MultiDrawIndexedIndirectCount ¶
func (p *RenderPassEncoder) MultiDrawIndexedIndirectCount( indirectBuffer *Buffer, indirectOffset uint64, countBuffer *Buffer, countOffset uint64, maxDrawCount uint32, )
MultiDrawIndexedIndirectCount draws indexed primitives with a GPU-provided draw count.
func (*RenderPassEncoder) MultiDrawIndirect ¶
func (p *RenderPassEncoder) MultiDrawIndirect(buffer *Buffer, offset uint64, drawCount uint32)
MultiDrawIndirect draws consecutive primitives with GPU-generated parameters. Each argument record is 16 bytes.
func (*RenderPassEncoder) MultiDrawIndirectCount ¶
func (p *RenderPassEncoder) MultiDrawIndirectCount( indirectBuffer *Buffer, indirectOffset uint64, countBuffer *Buffer, countOffset uint64, maxDrawCount uint32, )
MultiDrawIndirectCount draws primitives with a GPU-provided draw count. countBuffer must hold a uint32 count at countOffset. VAL-C2: requires FeatureMultiDrawIndirectCount.
func (*RenderPassEncoder) SetBindGroup ¶
func (p *RenderPassEncoder) SetBindGroup(index uint32, group *BindGroup, offsets []uint32)
SetBindGroup sets a bind group for the given index. The backend gets it once the pipeline's layout takes it at index.
func (*RenderPassEncoder) SetBlendConstant ¶
func (p *RenderPassEncoder) SetBlendConstant(color *gputypes.Color)
SetBlendConstant sets the blend constant color.
func (*RenderPassEncoder) SetIndexBuffer ¶
func (p *RenderPassEncoder) SetIndexBuffer(buffer *Buffer, format gputypes.IndexFormat, offset uint64)
SetIndexBuffer sets the index buffer.
Reference: Dawn RenderEncoderBase::APISetIndexBuffer
func (*RenderPassEncoder) SetPipeline ¶
func (p *RenderPassEncoder) SetPipeline(pipeline *RenderPipeline)
SetPipeline sets the active render pipeline.
func (*RenderPassEncoder) SetScissorRect ¶
func (p *RenderPassEncoder) SetScissorRect(rect gputypes.ScissorRect)
SetScissorRect sets the scissor rectangle for clipping.
func (*RenderPassEncoder) SetStencilReference ¶
func (p *RenderPassEncoder) SetStencilReference(reference uint32)
SetStencilReference sets the stencil reference value.
func (*RenderPassEncoder) SetVertexBuffer ¶
func (p *RenderPassEncoder) SetVertexBuffer(slot uint32, buffer *Buffer, offset uint64)
SetVertexBuffer sets a vertex buffer for the given slot.
Reference: Dawn RenderEncoderBase::APISetVertexBuffer
func (*RenderPassEncoder) SetViewport ¶
func (p *RenderPassEncoder) SetViewport(vp gputypes.Viewport)
SetViewport sets the viewport transformation.
type RenderPassTimestampWrites ¶
type RenderPassTimestampWrites struct {
QuerySet *QuerySet
BeginningOfPassWriteIndex *uint32
EndOfPassWriteIndex *uint32
}
RenderPassTimestampWrites describes timestamp query writes at render pass boundaries. The timestamps are in ticks of Queue.TimestampPeriod nanoseconds.
type RenderPipeline ¶
type RenderPipeline struct {
// contains filtered or unexported fields
}
RenderPipeline represents a configured render pipeline.
func (*RenderPipeline) GetBindGroupLayout ¶
func (p *RenderPipeline) GetBindGroupLayout(index uint32) *BindGroupLayout
GetBindGroupLayout returns the bind group layout at index of the pipeline's layout, or nil past its last group. For a pipeline created without a Layout these are the layouts derived from its shaders, to make its bind groups with. They belong to the pipeline and are released with it.
func (*RenderPipeline) Release ¶
func (p *RenderPipeline) Release()
Release drops the application's ownership reference to the render pipeline.
If the pipeline is still referenced by in-flight GPU submissions (Clone'd via SetPipeline), the HAL pipeline stays alive until the GPU completes and Triage drops all tracked refs. The onZero callback (set at CreateRenderPipeline) fires only when the last reference drops. ADR-056: unified resource lifecycle.
type RenderPipelineDescriptor ¶
type RenderPipelineDescriptor struct {
Label string
Layout *PipelineLayout
Vertex VertexState
Primitive gputypes.PrimitiveState
DepthStencil *DepthStencilState
Multisample gputypes.MultisampleState
Fragment *FragmentState
}
RenderPipelineDescriptor describes a render pipeline.
type RequestAdapterOptions ¶
type RequestAdapterOptions struct {
// PowerPreference indicates power consumption preference.
PowerPreference gputypes.PowerPreference
// ForceFallbackAdapter forces the use of a fallback (software) adapter.
ForceFallbackAdapter bool
// CompatibleSurface, if non-nil, indicates that the adapter must support
// rendering to this surface. For GLES backends, this triggers deferred
// adapter enumeration using the surface's GL context.
CompatibleSurface *Surface
}
RequestAdapterOptions controls adapter selection.
Following the WebGPU spec, CompatibleSurface is a typed *Surface pointer (not a raw handle). Backends that require a surface for adapter enumeration (e.g., GLES/OpenGL which needs a GL context) use this to perform deferred enumeration when RequestAdapter is called.
type Sampler ¶
type Sampler struct {
// contains filtered or unexported fields
}
Sampler represents a texture sampler.
func NewSamplerFromHAL ¶
NewSamplerFromHAL creates a Sampler wrapping an existing HAL sampler.
type SamplerDescriptor ¶
type SamplerDescriptor struct {
Label string
AddressModeU gputypes.AddressMode
AddressModeV gputypes.AddressMode
AddressModeW gputypes.AddressMode
MagFilter gputypes.FilterMode
MinFilter gputypes.FilterMode
MipmapFilter gputypes.FilterMode
LodMinClamp float32
LodMaxClamp float32
Compare gputypes.CompareFunction
Anisotropy uint16
}
SamplerDescriptor describes sampler creation parameters.
type ShaderModule ¶
type ShaderModule struct {
// contains filtered or unexported fields
}
ShaderModule represents a compiled shader module.
func (*ShaderModule) Release ¶
func (m *ShaderModule) Release()
Release destroys the shader module. Destruction is deferred until the GPU completes any submission that may reference this shader module.
type ShaderModuleDescriptor ¶
type ShaderModuleDescriptor struct {
Label string
WGSL string // WGSL source code
SPIRV []uint32 // SPIR-V bytecode (alternative to WGSL)
}
ShaderModuleDescriptor describes shader module creation parameters.
type StencilFaceState ¶
type StencilFaceState struct {
Compare gputypes.CompareFunction
FailOp gputypes.StencilOperation
DepthFailOp gputypes.StencilOperation
PassOp gputypes.StencilOperation
}
StencilFaceState describes stencil operations for a face.
type Surface ¶
type Surface struct {
// contains filtered or unexported fields
}
Surface represents a platform rendering surface (e.g., a window).
Surface delegates lifecycle management to core.Surface, which enforces the state machine: Unconfigured -> Configured -> Acquired -> Configured.
func NewSurfaceFromHAL ¶
NewSurfaceFromHAL creates a Surface wrapping an existing HAL surface. This constructor is used by backends that create surfaces externally (e.g., the Rust FFI backend).
Ownership of halSurface is transferred to the returned Surface.
func (*Surface) ActualExtent ¶
ActualExtent returns the actual swapchain dimensions after driver clamping.
On Vulkan, the driver may clamp the requested extent to its supported range (e.g., on X11 HiDPI where the compositor reports physical pixels that differ from the application's logical pixels). The returned values reflect what the swapchain was actually created with, which may differ from the configured SurfaceConfiguration.Width/Height.
On non-Vulkan backends (DX12, Metal, GLES, Software), the returned values match the configured dimensions since those backends do not clamp the extent. Returns (0, 0) if the surface is not configured.
Use this to size MSAA resolve textures, offscreen targets, and any other resources that must match the true swapchain size.
func (*Surface) Configure ¶
func (s *Surface) Configure(device *Device, config *SurfaceConfiguration) (err error)
Configure configures the surface for presentation. Must be called before GetCurrentTexture().
func (*Surface) DiscardTexture ¶
func (s *Surface) DiscardTexture()
DiscardTexture discards the acquired surface texture without presenting it. Use this if rendering failed or was canceled. If no texture is currently acquired, this is a no-op.
func (*Surface) GetCurrentTexture ¶
func (s *Surface) GetCurrentTexture() (*SurfaceTexture, bool, error)
GetCurrentTexture acquires the next texture for rendering. Returns the surface texture and whether the surface is suboptimal.
If a PrepareFrame hook is registered and reports changed dimensions, the surface is automatically reconfigured before acquiring.
func (*Surface) HAL ¶
HAL returns the underlying HAL surface for backward compatibility. Prefer using Surface methods instead of direct HAL access.
func (*Surface) Present ¶
func (s *Surface) Present(texture *SurfaceTexture) error
Present presents a surface texture to the screen.
func (*Surface) PresentWithDamage ¶
func (s *Surface) PresentWithDamage(texture *SurfaceTexture, damageRects []image.Rectangle) error
PresentWithDamage presents a surface texture to the screen, passing optional damage rectangles to the compositor.
damageRects specifies which regions of the surface changed this frame (physical pixels, top-left origin). When nil or empty, the entire surface is presented — identical to Present(). Backends that support damage rects (software partial blit, and in future: DX12 Present1, Vulkan VK_KHR_incremental_present, GLES eglSwapBuffersWithDamageKHR) use them as compositor hints; others accept and ignore them.
func (*Surface) SetPrepareFrame ¶
func (s *Surface) SetPrepareFrame(fn core.PrepareFrameFunc)
SetPrepareFrame registers a platform hook called before each GetCurrentTexture. If the hook returns changed=true with new dimensions, the surface is automatically reconfigured. This is the integration point for HiDPI/DPI change handling:
- macOS Metal: read CAMetalLayer.contentsScale
- Windows: handle WM_DPICHANGED
- Wayland: read wl_output.scale
Pass nil to remove the hook.
func (*Surface) SetPresentsWithTransaction ¶
SetPresentsWithTransaction toggles Core Animation transaction-based present on Metal surfaces. Enable during macOS live window resize so the drawable swap commits atomically with the resize CA transaction (Flutter/wgpu #3756 pattern); disable for normal rendering. No-op on non-Metal backends.
func (*Surface) Unconfigure ¶
func (s *Surface) Unconfigure()
Unconfigure removes the surface configuration.
type SurfaceCapabilities ¶
type SurfaceCapabilities struct {
// Formats lists the supported surface texture formats.
Formats []gputypes.TextureFormat
// PresentModes lists the supported presentation modes.
PresentModes []gputypes.PresentMode
// AlphaModes lists the supported composite alpha modes.
AlphaModes []gputypes.CompositeAlphaMode
// Usages are the usages the surface's textures can have, among them
// RenderAttachment: what a SurfaceConfiguration's Usage may hold.
Usages gputypes.TextureUsage
}
SurfaceCapabilities describes what a surface supports on this adapter.
type SurfaceConfiguration ¶
type SurfaceConfiguration struct {
Width uint32
Height uint32
Format gputypes.TextureFormat
Usage gputypes.TextureUsage
PresentMode gputypes.PresentMode
AlphaMode gputypes.CompositeAlphaMode
// ViewFormats lists the formats, besides Format, that views of the
// surface's textures may have. As in WebGPU, each may only differ from
// Format in being sRGB or not, such as BGRA8UnormSrgb for BGRA8Unorm.
ViewFormats []gputypes.TextureFormat
}
SurfaceConfiguration describes surface settings.
type SurfaceTarget ¶
type SurfaceTarget interface {
SurfaceTarget() (SurfaceTargetUnsafe, error)
}
SurfaceTarget provides the raw platform target used to create a Surface.
CreateSurfaceFromTarget samples SurfaceTarget once and retains the provider until the returned Surface is released. Retaining the provider keeps its Go ownership graph alive; the provider remains responsible for ensuring that the underlying native display and window stay valid for the same lifetime.
This is the Go equivalent of Rust wgpu's safe SurfaceTarget path.
type SurfaceTargetUnsafe ¶
type SurfaceTargetUnsafe struct {
// contains filtered or unexported fields
}
SurfaceTargetUnsafe identifies raw platform handles for surface creation. Construct values with one of the SurfaceTargetFrom* functions.
No ownership source is retained for an unsafe target. The caller must keep every referenced native object valid until the returned Surface is released. This is the Go equivalent of Rust wgpu's SurfaceTargetUnsafe::RawHandle.
func SurfaceTargetFromAndroidNativeWindow ¶
func SurfaceTargetFromAndroidNativeWindow(window uintptr) SurfaceTargetUnsafe
SurfaceTargetFromAndroidNativeWindow returns a raw ANativeWindow* target. Android has no meaningful display handle for this operation.
func SurfaceTargetFromMetalLayer ¶
func SurfaceTargetFromMetalLayer(layer uintptr) SurfaceTargetUnsafe
SurfaceTargetFromMetalLayer returns a raw CAMetalLayer* target.
func SurfaceTargetFromWaylandSurface ¶
func SurfaceTargetFromWaylandSurface(display, surface uintptr) SurfaceTargetUnsafe
SurfaceTargetFromWaylandSurface returns a raw wl_display*/wl_surface* target.
func SurfaceTargetFromWebCanvasID ¶
func SurfaceTargetFromWebCanvasID(id uintptr) SurfaceTargetUnsafe
SurfaceTargetFromWebCanvasID returns a browser canvas target identified by its data-raw-handle attribute. ID zero retains the legacy behavior of using the first canvas element in the document.
func SurfaceTargetFromWindowsHWND ¶
func SurfaceTargetFromWindowsHWND(hinstance, hwnd uintptr) SurfaceTargetUnsafe
SurfaceTargetFromWindowsHWND returns a raw Win32 surface target. hinstance may be zero when the backend can resolve the current module.
func SurfaceTargetFromXlibWindow ¶
func SurfaceTargetFromXlibWindow(display, window uintptr) SurfaceTargetUnsafe
SurfaceTargetFromXlibWindow returns a raw Xlib Display*/Window target.
type SurfaceTexture ¶
type SurfaceTexture struct {
// contains filtered or unexported fields
}
SurfaceTexture is a texture acquired from a surface for rendering.
func (*SurfaceTexture) AsTexture ¶
func (st *SurfaceTexture) AsTexture() *Texture
AsTexture returns the surface texture as a Texture, enabling use with Queue.WriteTexture() for direct CPU pixel upload without a render pass, and with copies. The surface must be configured with TextureUsageCopyDst for writes.
It is the same Texture every call, and lives as long as the acquisition: Release does nothing to it.
func (*SurfaceTexture) CreateView ¶
func (st *SurfaceTexture) CreateView(desc *TextureViewDescriptor) (*TextureView, error)
CreateView creates a texture view of this surface texture.
type Texture ¶
type Texture struct {
// contains filtered or unexported fields
}
Texture represents a GPU texture.
func NewTextureFromHAL ¶
func NewTextureFromHAL(halTexture hal.Texture, device *Device, format gputypes.TextureFormat) *Texture
NewTextureFromHAL creates a Texture wrapping an existing HAL texture. Used for backward compatibility and testing.
func (*Texture) Format ¶
func (t *Texture) Format() gputypes.TextureFormat
Format returns the texture format.
func (*Texture) Release ¶
func (t *Texture) Release()
Release destroys the texture. The underlying HAL texture is not freed immediately — destruction is deferred until the GPU completes any submission that may reference it. This prevents use-after-free on DX12/Vulkan. A Release while another goroutine submits waits for that Submit.
type TextureBarrier ¶
type TextureBarrier struct {
Texture *Texture
Range TextureRange
Usage TextureUsageTransition
}
TextureBarrier defines a texture state transition for synchronization. Required on Vulkan for layout transitions between render pass and copy operations. On Metal, GLES, and software backends this is a no-op.
type TextureCopy ¶
type TextureCopy struct {
Source ImageCopyTexture
Destination ImageCopyTexture
Size Extent3D
}
TextureCopy describes a texture-to-texture copy region. WebGPU spec: GPUCommandEncoder.copyTextureToTexture()
type TextureDescriptor ¶
type TextureDescriptor struct {
Label string
Size Extent3D
MipLevelCount uint32
SampleCount uint32
Dimension gputypes.TextureDimension
Format gputypes.TextureFormat
Usage gputypes.TextureUsage
ViewFormats []gputypes.TextureFormat
}
TextureDescriptor describes texture creation parameters.
type TextureRange ¶
type TextureRange struct {
Aspect gputypes.TextureAspect
BaseMipLevel uint32
MipLevelCount uint32
BaseArrayLayer uint32
ArrayLayerCount uint32
}
TextureRange specifies a range of texture subresources.
type TextureUsageTransition ¶
type TextureUsageTransition struct {
OldUsage gputypes.TextureUsage
NewUsage gputypes.TextureUsage
}
TextureUsageTransition defines a texture usage state transition.
type TextureView ¶
type TextureView struct {
// contains filtered or unexported fields
}
TextureView represents a view into a texture.
func NewTextureViewFromHAL ¶
func NewTextureViewFromHAL(halView hal.TextureView, device *Device) *TextureView
NewTextureViewFromHAL creates a TextureView wrapping an existing HAL texture view.
func (*TextureView) Release ¶
func (v *TextureView) Release()
Release drops the application's reference to the texture view. The HAL view stays while a bind group or an unsubmitted command buffer uses it, and after the last of them it is destroyed once the GPU completes the submissions that may reference it.
func (*TextureView) Texture ¶
func (v *TextureView) Texture() *Texture
Texture returns the parent Texture that this view was created from. Returns nil if the view has been released.
type TextureViewDescriptor ¶
type TextureViewDescriptor struct {
Label string
Format gputypes.TextureFormat
Dimension gputypes.TextureViewDimension
Aspect gputypes.TextureAspect
BaseMipLevel uint32
MipLevelCount uint32
BaseArrayLayer uint32
ArrayLayerCount uint32
}
TextureViewDescriptor describes texture view creation parameters.
type VertexState ¶
type VertexState struct {
Module *ShaderModule
EntryPoint string
Buffers []gputypes.VertexBufferLayout
}
VertexState describes the vertex shader stage.
Source Files
¶
- adapter_native.go
- autolayout.go
- bind_native.go
- binder.go
- buffer.go
- computepass_native.go
- descriptor.go
- device_native.go
- doc.go
- encoder_native.go
- encoder_pool.go
- error.go
- fence.go
- indirect.go
- instance_native.go
- logger.go
- map_pending.go
- map_types.go
- mapped_range.go
- pending_writes.go
- pipeline_interface.go
- pipeline_native.go
- query_native.go
- queue_native.go
- renderbundle_native.go
- renderpass_indirect_count.go
- renderpass_native.go
- sampler_native.go
- shader_native.go
- staging_belt.go
- surface_native.go
- surface_target.go
- texture_native.go
- types.go
- wrap.go
Directories
¶
| Path | Synopsis |
|---|---|
|
cmd
|
|
|
cgocheck
command
cgocheck checks a cgo package for a GOOS/GOARCH this machine has no sysroot for: it type checks the Go side with a faked "C" package and writes each file's cgo preamble out as a C (or Objective-C) file, so that clang --target=...
|
cgocheck checks a cgo package for a GOOS/GOARCH this machine has no sysroot for: it type checks the Go side with a faked "C" package and writes each file's cgo preamble out as a C (or Objective-C) file, so that clang --target=... |
|
dx12-test
command
Command dx12-test is an integration test for the DX12 backend.
|
Command dx12-test is an integration test for the DX12 backend. |
|
gles-test
command
Command gles-test is an integration test for the Pure Go GLES backend.
|
Command gles-test is an integration test for the Pure Go GLES backend. |
|
vk-cgo
command
Command vk-cgo rewrites the goffi Vulkan wrappers vk-gen writes (vk/commands_gen.go) into cgo: every wrapper calls one C trampoline per distinct C signature, through the function pointer the loader resolved.
|
Command vk-cgo rewrites the goffi Vulkan wrappers vk-gen writes (vk/commands_gen.go) into cgo: every wrapper calls one C trampoline per distinct C signature, through the function pointer the loader resolved. |
|
vk-gen
command
Command vk-gen generates Pure Go Vulkan bindings from vk.xml specification.
|
Command vk-gen generates Pure Go Vulkan bindings from vk.xml specification. |
|
vk-test
command
Command vk-test is an integration test for the Pure Go Vulkan backend.
|
Command vk-test is an integration test for the Pure Go Vulkan backend. |
|
vkloadercheck
command
vkloadercheck exercises the cgo loader path against the system Vulkan loader without creating an instance: dlopen, vkGetInstanceProcAddr and one global command, vkEnumerateInstanceVersion.
|
vkloadercheck exercises the cgo loader path against the system Vulkan loader without creating an instance: dlopen, vkGetInstanceProcAddr and one global command, vkEnumerateInstanceVersion. |
|
vulkan-renderpass-test
command
Command vulkan-renderpass-test validates the hypothesis that Intel Iris Xe driver bug is specific to VK_KHR_dynamic_rendering, not vkCreateGraphicsPipelines.
|
Command vulkan-renderpass-test validates the hypothesis that Intel Iris Xe driver bug is specific to VK_KHR_dynamic_rendering, not vkCreateGraphicsPipelines. |
|
vulkan-triangle
command
Command vulkan-triangle is a full integration test for the Vulkan backend.
|
Command vulkan-triangle is a full integration test for the Vulkan backend. |
|
wasmchrome
command
Command wasmchrome runs a js/wasm test binary in headless Chrome, where WebGPU is real, for go test's -exec:
|
Command wasmchrome runs a js/wasm test binary in headless Chrome, where WebGPU is real, for go test's -exec: |
|
wgpu-triangle
command
Command wgpu-triangle tests the wgpu public API rendering pipeline.
|
Command wgpu-triangle tests the wgpu public API rendering pipeline. |
|
wgpu-triangle-mt
command
Command wgpu-triangle tests the wgpu public API rendering pipeline.
|
Command wgpu-triangle tests the wgpu public API rendering pipeline. |
|
Package core provides validation and state management for WebGPU resources.
|
Package core provides validation and state management for WebGPU resources. |
|
track
Package track provides resource state tracking infrastructure.
|
Package track provides resource state tracking infrastructure. |
|
examples
|
|
|
browser-compute
command
Command browser-compute doubles four floats with a WebGPU compute shader in the browser and reads them back.
|
Command browser-compute doubles four floats with a WebGPU compute shader in the browser and reads them back. |
|
browser-test
command
|
|
|
compute-copy
command
Command compute-copy demonstrates GPU buffer copying via a compute shader.
|
Command compute-copy demonstrates GPU buffer copying via a compute shader. |
|
compute-particles
command
Command compute-particles demonstrates a GPU particle simulation using a compute shader.
|
Command compute-particles demonstrates a GPU particle simulation using a compute shader. |
|
compute-sum
command
Command compute-sum demonstrates a parallel reduction (sum) using a GPU compute shader.
|
Command compute-sum demonstrates a parallel reduction (sum) using a GPU compute shader. |
|
triangle-headless
command
Command triangle-headless renders a triangle to an offscreen texture and writes the result to a PNG file.
|
Command triangle-headless renders a triangle to an offscreen texture and writes the result to a PNG file. |
|
Package gputypes provides the WebGPU type definitions gowgpu's API is written in: enums, structs and constants, with no dependencies.
|
Package gputypes provides the WebGPU type definitions gowgpu's API is written in: enums, structs and constants, with no dependencies. |
|
Package hal provides the Hardware Abstraction Layer for WebGPU implementations.
|
Package hal provides the Hardware Abstraction Layer for WebGPU implementations. |
|
allbackends
Package allbackends imports all HAL backend implementations.
|
Package allbackends imports all HAL backend implementations. |
|
dx12
Package dx12 is the DirectX 12 backend of the HAL, for 64-bit Windows 10 and later, amd64 and arm64.
|
Package dx12 is the DirectX 12 backend of the HAL, for 64-bit Windows 10 and later, amd64 and arm64. |
|
dx12/d3d12
Package d3d12 provides low-level Direct3D 12 COM bindings for Windows.
|
Package d3d12 provides low-level Direct3D 12 COM bindings for Windows. |
|
dx12/d3dcompile
Package d3dcompile provides Pure Go bindings to d3dcompiler_47.dll.
|
Package d3dcompile provides Pure Go bindings to d3dcompiler_47.dll. |
|
dx12/dxgi
Package dxgi provides low-level DXGI (DirectX Graphics Infrastructure) COM bindings for Windows.
|
Package dxgi provides low-level DXGI (DirectX Graphics Infrastructure) COM bindings for Windows. |
|
gles
Package gles implements the HAL backend for OpenGL 3.3 and newer and OpenGL ES 3.0 and newer.
|
Package gles implements the HAL backend for OpenGL 3.3 and newer and OpenGL ES 3.0 and newer. |
|
gles/egl
Package egl provides EGL (EGL) context management for OpenGL ES on Linux.
|
Package egl provides EGL (EGL) context management for OpenGL ES on Linux. |
|
gles/gl
Package gl provides OpenGL constants and types for the GLES backend.
|
Package gl provides OpenGL constants and types for the GLES backend. |
|
gles/wgl
Package wgl provides Windows OpenGL (WGL) context management.
|
Package wgl provides Windows OpenGL (WGL) context management. |
|
metal
Package metal provides a Metal backend for the HAL.
|
Package metal provides a Metal backend for the HAL. |
|
metal/mslmap
Package mslmap builds the naga MSL binding map for the Metal backend.
|
Package mslmap builds the naga MSL binding map for the Metal backend. |
|
noop
Package noop provides a no-operation GPU backend.
|
Package noop provides a no-operation GPU backend. |
|
vulkan
Package vulkan implements the HAL backend for Vulkan.
|
Package vulkan implements the HAL backend for Vulkan. |
|
vulkan/memory
Package memory provides GPU memory allocation for Vulkan backend.
|
Package memory provides GPU memory allocation for Vulkan backend. |
|
vulkan/vk
Package vk holds the Vulkan bindings: types, constants and the function pointers of a Commands table, generated from the Khronos vk.xml.
|
Package vk holds the Vulkan bindings: types, constants and the function pointers of a Commands table, generated from the Khronos vk.xml. |
|
vulkan/vk/vknoop
Package vknoop provides do-nothing Vulkan entry points for benchmarking the vk wrappers without a driver.
|
Package vknoop provides do-nothing Vulkan entry points for benchmarking the vk wrappers without a driver. |
|
internal
|
|
|
dl
Package dl opens shared libraries and looks up their symbols at run time through dlopen and dlsym, so the backends that call EGL, GL, X11 or Wayland need none of those libraries, nor their headers, at build time.
|
Package dl opens shared libraries and looks up their symbols at run time through dlopen and dlsym, so the backends that call EGL, GL, X11 or Wayland need none of those libraries, nor their headers, at build time. |
|
indirect
Package indirect provides overflow-safe arithmetic for indirect draw spans.
|
Package indirect provides overflow-safe arithmetic for indirect draw spans. |
|
pipelinecache
Package pipelinecache provides shared disk persistence helpers for GPU driver pipeline caches (Vulkan VkPipelineCache and DX12 cached PSO blobs).
|
Package pipelinecache provides shared disk persistence helpers for GPU driver pipeline caches (Vulkan VkPipelineCache and DX12 cached PSO blobs). |
|
raytracing
Package raytracing provides core-level resource management for ray tracing acceleration structures (BLAS and TLAS).
|
Package raytracing provides core-level resource management for ray tracing acceleration structures (BLAS and TLAS). |
|
thread
Package thread provides thread abstraction for GPU operations.
|
Package thread provides thread abstraction for GPU operations. |