wgpu

package
v0.2.1 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Aug 21, 2026 License: MIT Imports: 8 Imported by: 0

Documentation

Index

Constants

View Source
const (
	ArrayLayerCountUndefined        = 0xffffffff
	CopyStrideUndefined             = 0xffffffff
	LimitU32Undefined        uint32 = 0xffffffff
	LimitU64Undefined        uint64 = 0xffffffffffffffff
	MipLevelCountUndefined          = 0xffffffff
	WholeMapSize                    = ^uint(0)
	WholeSize                       = 0xffffffffffffffff
)

Variables

This section is empty.

Functions

func FromBytes

func FromBytes[T any](data []byte) []T

FromBytes converts a slice of bytes to a slice of a specific type. This is useful for reading data from C functions that return byte arrays. Returns nil if the input slice is empty.

func HasInstanceFeature

func HasInstanceFeature(feature InstanceFeatureName) bool

HasInstanceFeature checks if the given instance feature is supported by the WebGPU implementation. Returns true if the feature is supported, false otherwise.

func ToBytes

func ToBytes[T any, E ~[]T](data E) []byte

ToBytes converts a slice of any type to a slice of bytes. This is useful for passing data to C functions that expect byte arrays. Returns nil if the input slice is empty.

Types

type Adapter

type Adapter struct {
	// contains filtered or unexported fields
}

Adapter represents a GPU adapter, which is a physical or virtual device that can be used to create WebGPU resources.

func (*Adapter) GetFeatures

func (a *Adapter) GetFeatures() []FeatureName

GetFeatures returns a list of all features supported by the adapter.

func (*Adapter) GetInfo

func (a *Adapter) GetInfo() AdapterInfo

GetInfo returns information about the adapter, such as vendor, device name, and backend type. Panics if the information cannot be retrieved.

func (*Adapter) GetLimits

func (a *Adapter) GetLimits() Limits

GetLimits returns the limits supported by the adapter. Returns the limits, panics if they cannot be retrieved.

func (*Adapter) HasFeature

func (a *Adapter) HasFeature(feature FeatureName) bool

HasFeature checks if the adapter supports the given feature. Returns true if the feature is supported, false otherwise.

func (*Adapter) Release

func (a *Adapter) Release()

Release releases the adapter and all associated resources. After calling this method, the adapter should no longer be used.

func (*Adapter) RequestDevice

func (a *Adapter) RequestDevice(descriptor *DeviceDescriptor) *Device

RequestDevice requests a logical GPU device from the adapter with the given descriptor. Panics if the request fails.

func (*Adapter) TryGetInfo

func (a *Adapter) TryGetInfo() (AdapterInfo, error)

TryGetInfo returns information about the adapter, or an error if it cannot be retrieved.

func (*Adapter) TryGetLimits

func (a *Adapter) TryGetLimits() (Limits, error)

TryGetLimits returns the limits supported by the adapter, or an error if they cannot be retrieved.

func (*Adapter) TryRequestDevice

func (a *Adapter) TryRequestDevice(descriptor *DeviceDescriptor) (*Device, error)

TryRequestDevice requests a logical GPU device from the adapter, returning the device and any error.

type AdapterInfo

type AdapterInfo struct {
	Vendor          string
	Architecture    string
	Device          string
	Description     string
	BackendType     BackendType
	AdapterType     AdapterType
	VendorID        uint32
	DeviceID        uint32
	SubgroupMinSize uint32
	SubgroupMaxSize uint32
}

AdapterInfo contains information about a GPU adapter, including vendor, device, and backend details.

type AdapterType

type AdapterType uint32
const (
	AdapterTypeDiscreteGPU   AdapterType = 1
	AdapterTypeIntegratedGPU AdapterType = 2
	AdapterTypeCPU           AdapterType = 3
	AdapterTypeUnknown       AdapterType = 4
)

func (AdapterType) String

func (a AdapterType) String() string

type AddressMode

type AddressMode uint32
const (
	AddressModeUndefined    AddressMode = 0
	AddressModeClampToEdge  AddressMode = 1
	AddressModeRepeat       AddressMode = 2
	AddressModeMirrorRepeat AddressMode = 3
)

type BackendType

type BackendType uint32
const (
	BackendTypeUndefined BackendType = 0
	BackendTypeNull      BackendType = 1
	BackendTypeWebGPU    BackendType = 2
	BackendTypeD3D11     BackendType = 3
	BackendTypeD3D12     BackendType = 4
	BackendTypeMetal     BackendType = 5
	BackendTypeVulkan    BackendType = 6
	BackendTypeOpenGL    BackendType = 7
	BackendTypeOpenGLES  BackendType = 8
)

func (BackendType) String

func (b BackendType) String() string

type BindGroup

type BindGroup struct {
	// contains filtered or unexported fields
}

BindGroup represents a group of resources that are bound together and used in GPU commands. Bind groups are created from a device using a bind group layout and a set of resources.

func (*BindGroup) Release

func (b *BindGroup) Release()

Release releases the bind group and all associated resources. After calling this method, the group should no longer be used.

func (*BindGroup) SetLabel

func (b *BindGroup) SetLabel(label string)

SetLabel sets the debug label for the bind group. This label appears in debuggers and validation layers.

type BindGroupDescriptor

type BindGroupDescriptor struct {
	Label   string
	Layout  *BindGroupLayout
	Entries []BindGroupEntry
}

BindGroupDescriptor describes a bind group, which is a collection of resources bound together for rendering.

type BindGroupEntry

type BindGroupEntry struct {
	Binding     uint32
	Buffer      *Buffer
	Offset      uint64
	Size        uint64
	Sampler     *Sampler
	TextureView *TextureView
}

BindGroupEntry represents a single entry in a bind group, binding a resource to a specific binding point.

type BindGroupLayout

type BindGroupLayout struct {
	// contains filtered or unexported fields
}

BindGroupLayout represents the interface for a bind group, defining the types and access patterns of its resources. Bind group layouts are created from a device and are used to create bind groups.

func (*BindGroupLayout) Release

func (b *BindGroupLayout) Release()

Release releases the bind group layout and all associated resources. After calling this method, the layout should no longer be used.

func (*BindGroupLayout) SetLabel

func (b *BindGroupLayout) SetLabel(label string)

SetLabel sets the debug label for the bind group layout. This label appears in debuggers and validation layers.

type BindGroupLayoutDescriptor

type BindGroupLayoutDescriptor struct {
	Label   string
	Entries []BindGroupLayoutEntry
}

BindGroupLayoutDescriptor describes a bind group layout, which defines the interface for a bind group.

type BindGroupLayoutEntry

type BindGroupLayoutEntry struct {
	Binding          uint32
	Visibility       ShaderStage
	BindingArraySize uint32
	Buffer           BufferBindingLayout
	Sampler          SamplerBindingLayout
	Texture          TextureBindingLayout
	StorageTexture   StorageTextureBindingLayout
}

BindGroupLayoutEntry describes a single entry in a bind group layout, defining the type and access pattern for a binding.

type BlendComponent

type BlendComponent struct {
	Operation BlendOperation
	SrcFactor BlendFactor
	DstFactor BlendFactor
}

BlendComponent describes how to blend a single color component (red, green, blue, or alpha) during rendering.

type BlendFactor

type BlendFactor uint32
const (
	BlendFactorUndefined         BlendFactor = 0
	BlendFactorZero              BlendFactor = 1
	BlendFactorOne               BlendFactor = 2
	BlendFactorSrc               BlendFactor = 3
	BlendFactorOneMinusSrc       BlendFactor = 4
	BlendFactorSrcAlpha          BlendFactor = 5
	BlendFactorOneMinusSrcAlpha  BlendFactor = 6
	BlendFactorDst               BlendFactor = 7
	BlendFactorOneMinusDst       BlendFactor = 8
	BlendFactorDstAlpha          BlendFactor = 9
	BlendFactorOneMinusDstAlpha  BlendFactor = 10
	BlendFactorSrcAlphaSaturated BlendFactor = 11
	BlendFactorConstant          BlendFactor = 12
	BlendFactorOneMinusConstant  BlendFactor = 13
	BlendFactorSrc1              BlendFactor = 14
	BlendFactorOneMinusSrc1      BlendFactor = 15
	BlendFactorSrc1Alpha         BlendFactor = 16
	BlendFactorOneMinusSrc1Alpha BlendFactor = 17
)

type BlendOperation

type BlendOperation uint32
const (
	BlendOperationUndefined       BlendOperation = 0
	BlendOperationAdd             BlendOperation = 1
	BlendOperationSubtract        BlendOperation = 2
	BlendOperationReverseSubtract BlendOperation = 3
	BlendOperationMin             BlendOperation = 4
	BlendOperationMax             BlendOperation = 5
)

type BlendState

type BlendState struct {
	Color BlendComponent
	Alpha BlendComponent
}

BlendState describes how to blend color and alpha components during rendering.

type Buffer

type Buffer struct {
	// contains filtered or unexported fields
}

Buffer represents a GPU buffer, which is a region of memory that can be used to store data. Buffers are created from a device and can be mapped for reading or writing.

func (*Buffer) AsImageCopyBuffer

func (b *Buffer) AsImageCopyBuffer(bytesPerRow, rowsPerImage uint32) TexelCopyBufferInfo

AsImageCopyBuffer returns a TexelCopyBufferInfo for use in image copy operations. The bytesPerRow and rowsPerImage parameters define the layout of the data.

func (*Buffer) Destroy

func (b *Buffer) Destroy()

Destroy destroys the buffer and frees all associated GPU resources.

func (*Buffer) GetConstMappedRange

func (b *Buffer) GetConstMappedRange(offset int, size int) []byte

MapModeRead GetConstMappedRange returns a slice of bytes representing the mapped range of the buffer for reading. The buffer must have been mapped with MapModeRead.

func (*Buffer) GetMapState

func (b *Buffer) GetMapState() BufferMapState

GetMapState returns the current mapping state of the buffer.

func (*Buffer) GetMappedRange

func (b *Buffer) GetMappedRange(offset int, size int) []byte

MapModeWrite GetMappedRange returns a slice of bytes representing the mapped range of the buffer for writing. The buffer must have been mapped with MapModeWrite.

func (*Buffer) GetSize

func (b *Buffer) GetSize() uint64

GetSize returns the size of the buffer in bytes.

func (*Buffer) GetUsage

func (b *Buffer) GetUsage() BufferUsage

GetUsage returns the usage flags for the buffer.

func (*Buffer) MapAsync

func (b *Buffer) MapAsync(mode MapMode, offset int, size int, callback BufferMapCallback) Future

MapAsync maps the buffer for reading or writing asynchronously. The mode specifies whether to map for reading or writing. The offset and size specify the range of the buffer to map. The callback is called when the mapping is complete. Returns a Future that can be used to wait for the mapping to complete.

func (*Buffer) Release

func (b *Buffer) Release()

Release releases the buffer and all associated resources. After calling this method, the buffer should no longer be used.

func (*Buffer) SetLabel

func (b *Buffer) SetLabel(label string)

SetLabel sets the debug label for the buffer. This label appears in debuggers and validation layers.

func (*Buffer) Unmap

func (b *Buffer) Unmap()

Unmap unmaps the buffer, flushing any writes if it was mapped for writing. After unmapping, the mapped range is no longer valid.

type BufferBindingLayout

type BufferBindingLayout struct {
	Type             BufferBindingType
	HasDynamicOffset bool
	MinBindingSize   uint64
}

BufferBindingLayout describes the layout for a buffer binding, including type and whether it has a dynamic offset.

type BufferBindingType

type BufferBindingType uint32
const (
	BufferBindingTypeBindingNotUsed  BufferBindingType = 0
	BufferBindingTypeUndefined       BufferBindingType = 1
	BufferBindingTypeUniform         BufferBindingType = 2
	BufferBindingTypeStorage         BufferBindingType = 3
	BufferBindingTypeReadOnlyStorage BufferBindingType = 4
)

type BufferDescriptor

type BufferDescriptor struct {
	Label            string
	Usage            BufferUsage
	Size             uint64
	MappedAtCreation bool
}

BufferDescriptor describes a buffer, including its size, usage flags, and whether it should be mapped at creation.

type BufferInitDescriptor

type BufferInitDescriptor struct {
	Label    string
	Usage    BufferUsage
	Contents []byte
}

BufferInitDescriptor describes a buffer to be created and initialized with data in a single operation.

type BufferMapCallback

type BufferMapCallback func(status MapAsyncStatus, message string)

BufferMapCallback is called when a buffer mapping operation completes. The callback receives the status of the operation and any error message.

type BufferMapState

type BufferMapState uint32
const (
	BufferMapStateUnmapped BufferMapState = 1
	BufferMapStatePending  BufferMapState = 2
	BufferMapStateMapped   BufferMapState = 3
)

type BufferUsage

type BufferUsage uint32
const (
	BufferUsageNone         BufferUsage = 0
	BufferUsageMapRead      BufferUsage = 1
	BufferUsageMapWrite     BufferUsage = 2
	BufferUsageCopySrc      BufferUsage = 4
	BufferUsageCopyDst      BufferUsage = 8
	BufferUsageIndex        BufferUsage = 16
	BufferUsageVertex       BufferUsage = 32
	BufferUsageUniform      BufferUsage = 64
	BufferUsageStorage      BufferUsage = 128
	BufferUsageIndirect     BufferUsage = 256
	BufferUsageQueryResolve BufferUsage = 512
	BufferUsageTexelBuffer  BufferUsage = 1024
)

type Color

type Color struct {
	R float64
	G float64
	B float64
	A float64
}

Color represents an RGBA color with double-precision floating-point components.

type ColorTargetState

type ColorTargetState struct {
	Format    TextureFormat
	Blend     *BlendState
	WriteMask ColorWriteMask
}

ColorTargetState describes the state of a color target in a render pipeline, including format, blend, and write mask.

type ColorWriteMask

type ColorWriteMask uint32
const (
	ColorWriteMaskNone  ColorWriteMask = 0
	ColorWriteMaskRed   ColorWriteMask = 1
	ColorWriteMaskGreen ColorWriteMask = 2
	ColorWriteMaskBlue  ColorWriteMask = 4
	ColorWriteMaskAlpha ColorWriteMask = 8
	ColorWriteMaskAll   ColorWriteMask = 15
)

type CommandBuffer

type CommandBuffer struct {
	// contains filtered or unexported fields
}

CommandBuffer represents a sequence of GPU commands that can be submitted to a queue. Command buffers are created from a command encoder and contain recorded commands.

func (*CommandBuffer) Release

func (c *CommandBuffer) Release()

Release releases the command buffer and all associated resources. After calling this method, the buffer should no longer be used.

func (*CommandBuffer) SetLabel

func (c *CommandBuffer) SetLabel(label string)

SetLabel sets the debug label for the command buffer. This label appears in debuggers and validation layers.

type CommandBufferDescriptor

type CommandBufferDescriptor struct {
	Label string
}

CommandBufferDescriptor describes a command buffer, primarily for setting its label.

type CommandEncoder

type CommandEncoder struct {
	// contains filtered or unexported fields
}

CommandEncoder encodes a sequence of GPU commands that can be submitted to a queue. Command encoders are created from a device and are used to build command buffers.

func (*CommandEncoder) BeginComputePass

func (c *CommandEncoder) BeginComputePass(descriptor *ComputePassDescriptor) *ComputePassEncoder

BeginComputePass begins a compute pass and returns a compute pass encoder. The descriptor can be used to set the label and timestamp writes for the pass.

func (*CommandEncoder) BeginRenderPass

func (c *CommandEncoder) BeginRenderPass(descriptor RenderPassDescriptor) *RenderPassEncoder

BeginRenderPass begins a render pass and returns a render pass encoder. The descriptor defines the color attachments, depth stencil attachment, and other settings for the pass.

func (*CommandEncoder) ClearBuffer

func (c *CommandEncoder) ClearBuffer(buffer *Buffer, offset uint64, size uint64)

ClearBuffer fills a buffer with zeros or a specific value. The offset and size specify the range of the buffer to clear. If size is 0, the whole buffer is cleared.

func (*CommandEncoder) CopyBufferToBuffer

func (c *CommandEncoder) CopyBufferToBuffer(source *Buffer, sourceOffset uint64, destination *Buffer, destinationOffset uint64, size uint64)

CopyBufferToBuffer copies data from one buffer to another. The source and destination buffers must have the CopySrc and CopyDst usage flags respectively.

func (*CommandEncoder) CopyBufferToTexture

func (c *CommandEncoder) CopyBufferToTexture(source TexelCopyBufferInfo, destination TexelCopyTextureInfo, copySize Extent3D)

CopyBufferToTexture copies data from a buffer to a texture. The source defines the buffer and layout, and the destination defines the texture and region.

func (*CommandEncoder) CopyTextureToBuffer

func (c *CommandEncoder) CopyTextureToBuffer(source TexelCopyTextureInfo, destination TexelCopyBufferInfo, copySize Extent3D)

CopyTextureToBuffer copies data from a texture to a buffer. The source defines the texture and region, and the destination defines the buffer and layout.

func (*CommandEncoder) CopyTextureToTexture

func (c *CommandEncoder) CopyTextureToTexture(source TexelCopyTextureInfo, destination TexelCopyTextureInfo, copySize Extent3D)

CopyTextureToTexture copies data from one texture to another. The source and destination define their respective textures and regions.

func (*CommandEncoder) Finish

func (c *CommandEncoder) Finish(descriptor *CommandBufferDescriptor) *CommandBuffer

Finish finishes recording commands and returns a command buffer. The descriptor can be used to set the label of the command buffer.

func (*CommandEncoder) InsertDebugMarker

func (c *CommandEncoder) InsertDebugMarker(markerLabel string)

InsertDebugMarker inserts a debug marker into the command encoder. The marker label is used to identify the marker in debuggers and profilers.

func (*CommandEncoder) PopDebugGroup

func (c *CommandEncoder) PopDebugGroup()

PopDebugGroup pops the most recently pushed debug group from the command encoder.

func (*CommandEncoder) PushDebugGroup

func (c *CommandEncoder) PushDebugGroup(groupLabel string)

PushDebugGroup pushes a debug group into the command encoder with the given label. Debug groups can be nested and are used to group commands in debuggers and profilers.

func (*CommandEncoder) Release

func (c *CommandEncoder) Release()

Release releases the command encoder and all associated resources. After calling this method, the encoder should no longer be used.

func (*CommandEncoder) ResolveQuerySet

func (c *CommandEncoder) ResolveQuerySet(querySet *QuerySet, firstQuery uint32, queryCount uint32, destination *Buffer, destinationOffset uint64)

ResolveQuerySet resolves an occlusion or timestamp query set to a buffer. The query results are written to the destination buffer starting at destinationOffset.

func (*CommandEncoder) SetLabel

func (c *CommandEncoder) SetLabel(label string)

SetLabel sets the debug label for the command encoder. This label appears in debuggers and validation layers.

func (*CommandEncoder) WriteTimestamp

func (c *CommandEncoder) WriteTimestamp(querySet *QuerySet, queryIndex uint32)

WriteTimestamp writes a timestamp to a query set at the current point in the command encoder. Timestamps can be used to measure GPU execution times.

type CommandEncoderDescriptor

type CommandEncoderDescriptor struct {
	Label string
}

CommandEncoderDescriptor describes a command encoder, primarily for setting its label.

type CompareFunction

type CompareFunction uint32
const (
	CompareFunctionUndefined    CompareFunction = 0
	CompareFunctionNever        CompareFunction = 1
	CompareFunctionLess         CompareFunction = 2
	CompareFunctionEqual        CompareFunction = 3
	CompareFunctionLessEqual    CompareFunction = 4
	CompareFunctionGreater      CompareFunction = 5
	CompareFunctionNotEqual     CompareFunction = 6
	CompareFunctionGreaterEqual CompareFunction = 7
	CompareFunctionAlways       CompareFunction = 8
)

type CompatibilityModeLimits

type CompatibilityModeLimits struct {
	MaxStorageBuffersInVertexStage    uint32
	MaxStorageTexturesInVertexStage   uint32
	MaxStorageBuffersInFragmentStage  uint32
	MaxStorageTexturesInFragmentStage uint32
}

CompatibilityModeLimits contains limits specific to WebGPU compatibility mode.

type CompilationMessage

type CompilationMessage struct {
	Message string
	Type    CompilationMessageType
	LineNum uint64
	LinePos uint64
	Offset  uint64
	Length  uint64
}

CompilationMessage contains a message from shader compilation, including type, text, and location information.

type CompilationMessageType

type CompilationMessageType uint32
const (
	CompilationMessageTypeError   CompilationMessageType = 1
	CompilationMessageTypeWarning CompilationMessageType = 2
	CompilationMessageTypeInfo    CompilationMessageType = 3
)

type ComponentSwizzle

type ComponentSwizzle uint32
const (
	ComponentSwizzleUndefined ComponentSwizzle = 0
	ComponentSwizzleZero      ComponentSwizzle = 1
	ComponentSwizzleOne       ComponentSwizzle = 2
	ComponentSwizzleR         ComponentSwizzle = 3
	ComponentSwizzleG         ComponentSwizzle = 4
	ComponentSwizzleB         ComponentSwizzle = 5
	ComponentSwizzleA         ComponentSwizzle = 6
)

type CompositeAlphaMode

type CompositeAlphaMode uint32
const (
	CompositeAlphaModeAuto            CompositeAlphaMode = 0
	CompositeAlphaModeOpaque          CompositeAlphaMode = 1
	CompositeAlphaModePremultiplied   CompositeAlphaMode = 2
	CompositeAlphaModeUnpremultiplied CompositeAlphaMode = 3
	CompositeAlphaModeInherit         CompositeAlphaMode = 4
)

type ComputePassDescriptor

type ComputePassDescriptor struct {
	Label           string
	TimestampWrites *PassTimestampWrites
}

ComputePassDescriptor describes a compute pass, including label and timestamp writes.

type ComputePassEncoder

type ComputePassEncoder struct {
	// contains filtered or unexported fields
}

ComputePassEncoder encodes compute commands that will be dispatched to the GPU. Compute pass encoders are created from a command encoder and are used to issue compute work.

func (*ComputePassEncoder) DispatchWorkgroups

func (c *ComputePassEncoder) DispatchWorkgroups(workgroupCountX uint32, workgroupCountY uint32, workgroupCountZ uint32)

DispatchWorkgroups dispatches compute workgroups with the specified dimensions. Each workgroup runs the compute shader with the given number of threads.

func (*ComputePassEncoder) DispatchWorkgroupsIndirect

func (c *ComputePassEncoder) DispatchWorkgroupsIndirect(indirectBuffer *Buffer, indirectOffset uint64)

DispatchWorkgroupsIndirect dispatches compute workgroups indirectly using parameters from a buffer. The indirectBuffer contains the workgroup count parameters and indirectOffset specifies the offset into that buffer.

func (*ComputePassEncoder) End

func (c *ComputePassEncoder) End()

End ends the compute pass. After calling this method, no more commands can be recorded in this pass.

func (*ComputePassEncoder) InsertDebugMarker

func (c *ComputePassEncoder) InsertDebugMarker(markerLabel string)

InsertDebugMarker inserts a debug marker into the compute pass. The marker label is used to identify the marker in debuggers and profilers.

func (*ComputePassEncoder) PopDebugGroup

func (c *ComputePassEncoder) PopDebugGroup()

PopDebugGroup pops the most recently pushed debug group from the compute pass.

func (*ComputePassEncoder) PushDebugGroup

func (c *ComputePassEncoder) PushDebugGroup(groupLabel string)

PushDebugGroup pushes a debug group into the compute pass with the given label. Debug groups can be nested and are used to group commands in debuggers and profilers.

func (*ComputePassEncoder) Release

func (c *ComputePassEncoder) Release()

Release releases the compute pass encoder and all associated resources. After calling this method, the encoder should no longer be used.

func (*ComputePassEncoder) SetBindGroup

func (c *ComputePassEncoder) SetBindGroup(groupIndex uint32, group *BindGroup, dynamicOffsets []uint32)

SetBindGroup sets a bind group to be used for subsequent compute commands. The groupIndex specifies which bind group slot to use. The dynamicOffsets provide values for any dynamic buffer offsets in the bind group.

func (*ComputePassEncoder) SetLabel

func (c *ComputePassEncoder) SetLabel(label string)

SetLabel sets the debug label for the compute pass encoder. This label appears in debuggers and validation layers.

func (*ComputePassEncoder) SetPipeline

func (c *ComputePassEncoder) SetPipeline(pipeline *ComputePipeline)

SetPipeline sets the compute pipeline to be used for subsequent compute commands.

type ComputePipeline

type ComputePipeline struct {
	// contains filtered or unexported fields
}

ComputePipeline represents a compute pipeline that can execute compute shaders. Compute pipelines are created from a device and a compute pipeline descriptor.

func (*ComputePipeline) GetBindGroupLayout

func (c *ComputePipeline) GetBindGroupLayout(groupIndex uint32) *BindGroupLayout

GetBindGroupLayout returns the bind group layout at the specified group index for this compute pipeline. This layout defines the interface for bind groups used with this pipeline.

func (*ComputePipeline) Release

func (c *ComputePipeline) Release()

Release releases the compute pipeline and all associated resources. After calling this method, the pipeline should no longer be used.

func (*ComputePipeline) SetLabel

func (c *ComputePipeline) SetLabel(label string)

SetLabel sets the debug label for the compute pipeline. This label appears in debuggers and validation layers.

type ComputePipelineDescriptor

type ComputePipelineDescriptor struct {
	Label   string
	Layout  *PipelineLayout
	Compute ComputeState
}

ComputePipelineDescriptor describes a compute pipeline, including label, layout, and compute stage.

type ComputeState

type ComputeState struct {
	Module     *ShaderModule
	EntryPoint string
	Constants  map[string]float64
}

ComputeState describes the compute stage of a compute pipeline, including the shader module and entry point.

type CreateComputePipelineAsyncCallback

type CreateComputePipelineAsyncCallback func(status CreatePipelineAsyncStatus, pipeline *ComputePipeline, message string)

CreateComputePipelineAsyncCallback is called when an asynchronous compute pipeline creation completes. The callback receives the status, the created pipeline (if successful), and any error message.

type CreatePipelineAsyncStatus

type CreatePipelineAsyncStatus uint32
const (
	CreatePipelineAsyncStatusSuccess           CreatePipelineAsyncStatus = 1
	CreatePipelineAsyncStatusCallbackCancelled CreatePipelineAsyncStatus = 2
	CreatePipelineAsyncStatusValidationError   CreatePipelineAsyncStatus = 3
	CreatePipelineAsyncStatusInternalError     CreatePipelineAsyncStatus = 4
)

type CreateRenderPipelineAsyncCallback

type CreateRenderPipelineAsyncCallback func(status CreatePipelineAsyncStatus, pipeline *RenderPipeline, message string)

CreateRenderPipelineAsyncCallback is called when an asynchronous render pipeline creation completes. The callback receives the status, the created pipeline (if successful), and any error message.

type CullMode

type CullMode uint32
const (
	CullModeUndefined CullMode = 0
	CullModeNone      CullMode = 1
	CullModeFront     CullMode = 2
	CullModeBack      CullMode = 3
)

type DepthStencilState

type DepthStencilState struct {
	Format              TextureFormat
	DepthWriteEnabled   OptionalBool
	DepthCompare        CompareFunction
	StencilFront        StencilFaceState
	StencilBack         StencilFaceState
	StencilReadMask     uint32
	StencilWriteMask    uint32
	DepthBias           int32
	DepthBiasSlopeScale float32
	DepthBiasClamp      float32
}

DepthStencilState describes the depth-stencil state for a render pipeline, including format, compare function, and stencil operations.

type Device

type Device struct {
	// contains filtered or unexported fields
}

Device represents a logical GPU device that can be used to create resources and execute commands. It is the main interface for interacting with the GPU.

func (*Device) CreateBindGroup

func (d *Device) CreateBindGroup(descriptor BindGroupDescriptor) *BindGroup

CreateBindGroup creates a bind group from the given descriptor, which defines a set of resources to be bound together.

func (*Device) CreateBindGroupLayout

func (d *Device) CreateBindGroupLayout(descriptor BindGroupLayoutDescriptor) *BindGroupLayout

CreateBindGroupLayout creates a bind group layout from the given descriptor, which defines the interface for a bind group.

func (*Device) CreateBuffer

func (d *Device) CreateBuffer(descriptor BufferDescriptor) *Buffer

CreateBuffer creates a new buffer with the given descriptor. Buffers are used to store data that can be read and written by shaders.

func (*Device) CreateBufferInit

func (d *Device) CreateBufferInit(descriptor BufferInitDescriptor) *Buffer

CreateBufferInit creates a buffer and initializes it with the given contents in a single operation. This is more efficient than creating and then writing to the buffer separately.

func (*Device) CreateCommandEncoder

func (d *Device) CreateCommandEncoder(descriptor *CommandEncoderDescriptor) *CommandEncoder

CreateCommandEncoder creates a command encoder from the given descriptor. Command encoders are used to record commands that will be submitted to the GPU queue.

func (*Device) CreateComputePipeline

func (d *Device) CreateComputePipeline(descriptor ComputePipelineDescriptor) *ComputePipeline

CreateComputePipeline creates a compute pipeline from the given descriptor. Compute pipelines execute compute shaders on the GPU.

func (*Device) CreateComputePipelineAsync

func (d *Device) CreateComputePipelineAsync(descriptor ComputePipelineDescriptor, callback CreateComputePipelineAsyncCallback) Future

CreateComputePipelineAsync creates a compute pipeline asynchronously from the given descriptor. Returns a Future that can be used to wait for the pipeline to be created. The callback is called when the pipeline is ready or an error occurs.

func (*Device) CreatePipelineLayout

func (d *Device) CreatePipelineLayout(descriptor PipelineLayoutDescriptor) *PipelineLayout

CreatePipelineLayout creates a pipeline layout from the given descriptor. Pipeline layouts define the resource bindings used by pipelines.

func (*Device) CreateQuerySet

func (d *Device) CreateQuerySet(descriptor QuerySetDescriptor) QuerySet

CreateQuerySet creates a query set from the given descriptor. Query sets are used to collect timestamp and occlusion query results.

func (*Device) CreateRenderBundleEncoder

func (d *Device) CreateRenderBundleEncoder(descriptor RenderBundleEncoderDescriptor) RenderBundleEncoder

CreateRenderBundleEncoder creates a render bundle encoder from the given descriptor. Render bundles are pre-recorded render commands that can be executed efficiently multiple times.

func (*Device) CreateRenderPipeline

func (d *Device) CreateRenderPipeline(descriptor RenderPipelineDescriptor) *RenderPipeline

CreateRenderPipeline creates a render pipeline from the given descriptor. Render pipelines define how graphics are rendered.

func (*Device) CreateRenderPipelineAsync

func (d *Device) CreateRenderPipelineAsync(descriptor RenderPipelineDescriptor, callback CreateRenderPipelineAsyncCallback) Future

CreateRenderPipelineAsync creates a render pipeline asynchronously from the given descriptor. Returns a Future that can be used to wait for the pipeline to be created. The callback is called when the pipeline is ready or an error occurs.

func (*Device) CreateSampler

func (d *Device) CreateSampler(descriptor *SamplerDescriptor) *Sampler

CreateSampler creates a sampler from the given descriptor. Samplers define how textures are sampled in shaders.

func (*Device) CreateShaderModule

func (d *Device) CreateShaderModule(descriptor ShaderModuleDescriptor) *ShaderModule

CreateShaderModule creates a shader module from the given descriptor. Shader modules contain shader code (WGSL or SPIR-V) that can be used in pipelines.

func (*Device) CreateTexture

func (d *Device) CreateTexture(descriptor *TextureDescriptor) *Texture

CreateTexture creates a new texture with the given descriptor. Textures are used to store image data that can be sampled by shaders.

func (*Device) Destroy

func (d *Device) Destroy()

Destroy destroys the device and all associated resources. This is similar to Release but also frees all GPU resources associated with the device.

func (*Device) GetAdapterInfo

func (d *Device) GetAdapterInfo() (AdapterInfo, error)

GetAdapterInfo returns information about the adapter that created this device. Returns the adapter info and an error if it cannot be retrieved.

func (*Device) GetFeatures

func (d *Device) GetFeatures() []FeatureName

GetFeatures returns a list of all features supported by the device.

func (*Device) GetLimits

func (d *Device) GetLimits() (Limits, error)

GetLimits returns the limits supported by the device. Returns the limits and an error if they cannot be retrieved.

func (*Device) GetQueue

func (d *Device) GetQueue() *Queue

GetQueue returns the default queue for this device. The queue is used to submit commands to the GPU.

func (*Device) HasFeature

func (d *Device) HasFeature(feature FeatureName) bool

HasFeature checks if the device supports the given feature. Returns true if the feature is supported, false otherwise.

func (*Device) PopErrorScope

func (d *Device) PopErrorScope(callback PopErrorScopeCallback)

PopErrorScope pops an error scope from the device's error scope stack and calls the callback with the result. The callback is called with the error type and message, or no error if the scope was empty.

func (*Device) PushErrorScope

func (d *Device) PushErrorScope(filter ErrorFilter)

PushErrorScope pushes an error scope onto the device's error scope stack. Errors that match the filter will be captured in the scope.

func (*Device) Release

func (d *Device) Release()

Release releases the device and all associated resources. After calling this method, the device should no longer be used.

func (*Device) SetLabel

func (d *Device) SetLabel(label string)

SetLabel sets the debug label for the device. This label appears in debuggers and validation layers.

func (*Device) Try

func (d *Device) Try(fn func(), filters ...ErrorFilter) error

Try executes the given function and captures any errors that occur. The optional filters specify which error types to capture; if not provided, all error types are captured. Returns the captured error, if any.

type DeviceDescriptor

type DeviceDescriptor struct {
	Label                   string
	RequiredFeatures        []FeatureName
	RequiredLimits          *Limits
	DefaultQueue            QueueDescriptor
	DeviceLostCallback      DeviceLostCallback
	UncapturedErrorCallback UncapturedErrorCallback
}

DeviceDescriptor describes a logical device, including required features, limits, and callbacks for errors and device loss.

type DeviceLostCallback

type DeviceLostCallback func(device *Device, reason DeviceLostReason, message string)

DeviceLostCallback is called when a device is lost. The callback receives the device, the reason for loss, and a message describing what happened.

type DeviceLostReason

type DeviceLostReason uint32
const (
	DeviceLostReasonUnknown           DeviceLostReason = 1
	DeviceLostReasonDestroyed         DeviceLostReason = 2
	DeviceLostReasonCallbackCancelled DeviceLostReason = 3
	DeviceLostReasonFailedCreation    DeviceLostReason = 4
)

type ErrorFilter

type ErrorFilter uint32
const (
	ErrorFilterValidation  ErrorFilter = 1
	ErrorFilterOutOfMemory ErrorFilter = 2
	ErrorFilterInternal    ErrorFilter = 3
)

func (ErrorFilter) String

func (e ErrorFilter) String() string

type ErrorType

type ErrorType uint32
const (
	ErrorTypeNoError     ErrorType = 1
	ErrorTypeValidation  ErrorType = 2
	ErrorTypeOutOfMemory ErrorType = 3
	ErrorTypeInternal    ErrorType = 4
	ErrorTypeUnknown     ErrorType = 5
)

func (ErrorType) String

func (e ErrorType) String() string

type Extent3D

type Extent3D struct {
	Width              uint32
	Height             uint32
	DepthOrArrayLayers uint32
}

Extent3D defines the size of a resource in three dimensions, used for textures and other resources.

type FeatureLevel

type FeatureLevel uint32
const (
	FeatureLevelUndefined     FeatureLevel = 0
	FeatureLevelCompatibility FeatureLevel = 1
	FeatureLevelCore          FeatureLevel = 2
)

type FeatureName

type FeatureName uint32
const (
	FeatureNameCoreFeaturesAndLimits          FeatureName = 1
	FeatureNameDepthClipControl               FeatureName = 2
	FeatureNameDepth32FloatStencil8           FeatureName = 3
	FeatureNameTextureCompressionBC           FeatureName = 4
	FeatureNameTextureCompressionBCSliced3D   FeatureName = 5
	FeatureNameTextureCompressionETC2         FeatureName = 6
	FeatureNameTextureCompressionASTC         FeatureName = 7
	FeatureNameTextureCompressionASTCSliced3D FeatureName = 8
	FeatureNameTimestampQuery                 FeatureName = 9
	FeatureNameIndirectFirstInstance          FeatureName = 10
	FeatureNameShaderF16                      FeatureName = 11
	FeatureNameRG11B10UfloatRenderable        FeatureName = 12
	FeatureNameBGRA8UnormStorage              FeatureName = 13
	FeatureNameFloat32Filterable              FeatureName = 14
	FeatureNameFloat32Blendable               FeatureName = 15
	FeatureNameClipDistances                  FeatureName = 16
	FeatureNameDualSourceBlending             FeatureName = 17
	FeatureNameSubgroups                      FeatureName = 18
	FeatureNameTextureFormatsTier1            FeatureName = 19
	FeatureNameTextureFormatsTier2            FeatureName = 20
	FeatureNamePrimitiveIndex                 FeatureName = 21
	FeatureNameTextureComponentSwizzle        FeatureName = 22
)

type FilterMode

type FilterMode uint32
const (
	FilterModeUndefined FilterMode = 0
	FilterModeNearest   FilterMode = 1
	FilterModeLinear    FilterMode = 2
)

type FragmentState

type FragmentState struct {
	Module     *ShaderModule
	EntryPoint string
	Constants  map[string]float64
	Targets    []ColorTargetState
}

FragmentState describes the fragment stage of a render pipeline, including shader module, entry point, constants, and color targets.

type FrontFace

type FrontFace uint32
const (
	FrontFaceUndefined FrontFace = 0
	FrontFaceCCW       FrontFace = 1
	FrontFaceCW        FrontFace = 2
)

type Future

type Future struct {
	// contains filtered or unexported fields
}

Future represents a handle to an asynchronous operation that can be waited on.

type IndexFormat

type IndexFormat uint32
const (
	IndexFormatUndefined IndexFormat = 0
	IndexFormatUint16    IndexFormat = 1
	IndexFormatUint32    IndexFormat = 2
)

type Instance

type Instance struct {
	// contains filtered or unexported fields
}

Instance is a WebGPU instance, which serves as the entry point for all WebGPU operations. It manages the underlying GPU backend and is used to request adapters.

func CreateInstance

func CreateInstance(descriptor *InstanceDescriptor) *Instance

CreateInstance creates a new WebGPU instance with optional descriptor. The instance is the entry point for all WebGPU operations.

func (*Instance) CreateSurface

func (i *Instance) CreateSurface(descriptor SurfaceDescriptor) *Surface

CreateSurface creates a surface for rendering to a window. The surface is configured for the specified descriptor, which defines how the surface should be presented.

func (*Instance) GetWGSLLanguageFeatures

func (i *Instance) GetWGSLLanguageFeatures() []WGSLLanguageFeatureName

GetWGSLLanguageFeatures returns all WGSL language features supported by the instance.

func (*Instance) HasWGSLLanguageFeature

func (i *Instance) HasWGSLLanguageFeature(feature WGSLLanguageFeatureName) bool

HasWGSLLanguageFeature checks if the instance supports the given WGSL language feature. Returns true if the feature is supported, false otherwise.

func (*Instance) ProcessEvents

func (i *Instance) ProcessEvents()

ProcessEvents processes any pending events in the instance, such as callbacks and device lost notifications. This must be called periodically to ensure callbacks are executed.

func (*Instance) Release

func (i *Instance) Release()

Release releases the instance and all associated resources. After calling this method, the instance should no longer be used.

func (*Instance) RequestAdapter

func (i *Instance) RequestAdapter(options *RequestAdapterOptions) (*Adapter, error)

RequestAdapter requests a GPU adapter from the instance based on the provided options. Returns the adapter and an error if the request fails.

func (*Instance) Wait

func (i *Instance) Wait(future Future, timeout time.Duration) error

Wait blocks the current thread until the specified future completes or the timeout expires. Returns an error if the wait fails or times out.

func (*Instance) WaitAny

func (i *Instance) WaitAny(futures []Future, timeout time.Duration) error

WaitAny blocks the current thread until any of the specified futures completes or the timeout expires. Returns an error if the wait fails or times out.

type InstanceDescriptor

type InstanceDescriptor struct {
	RequiredFeatures []InstanceFeatureName
	RequiredLimits   *InstanceLimits
}

InstanceDescriptor describes an instance, including required features and limits.

type InstanceFeatureName

type InstanceFeatureName uint32
const (
	InstanceFeatureNameTimedWaitAny              InstanceFeatureName = 1
	InstanceFeatureNameShaderSourceSPIRV         InstanceFeatureName = 2
	InstanceFeatureNameMultipleDevicesPerAdapter InstanceFeatureName = 3
)

func GetInstanceFeatures

func GetInstanceFeatures() []InstanceFeatureName

GetInstanceFeatures returns a list of all instance-level features supported by the WebGPU implementation.

type InstanceLimits

type InstanceLimits struct {
	TimedWaitAnyMaxCount int
}

InstanceLimits contains instance-level limits, such as the maximum number of futures that can be waited on concurrently.

func GetInstanceLimits

func GetInstanceLimits() (InstanceLimits, error)

GetInstanceLimits returns the instance-level limits supported by the WebGPU implementation. Returns the limits and an error if they cannot be retrieved.

type Limits

type Limits struct {
	MaxTextureDimension1D                     uint32
	MaxTextureDimension2D                     uint32
	MaxTextureDimension3D                     uint32
	MaxTextureArrayLayers                     uint32
	MaxBindGroups                             uint32
	MaxBindGroupsPlusVertexBuffers            uint32
	MaxBindingsPerBindGroup                   uint32
	MaxDynamicUniformBuffersPerPipelineLayout uint32
	MaxDynamicStorageBuffersPerPipelineLayout uint32
	MaxSampledTexturesPerShaderStage          uint32
	MaxSamplersPerShaderStage                 uint32
	MaxStorageBuffersPerShaderStage           uint32
	MaxStorageTexturesPerShaderStage          uint32
	MaxUniformBuffersPerShaderStage           uint32
	MaxUniformBufferBindingSize               uint64
	MaxStorageBufferBindingSize               uint64
	MinUniformBufferOffsetAlignment           uint32
	MinStorageBufferOffsetAlignment           uint32
	MaxVertexBuffers                          uint32
	MaxBufferSize                             uint64
	MaxVertexAttributes                       uint32
	MaxVertexBufferArrayStride                uint32
	MaxInterStageShaderVariables              uint32
	MaxColorAttachments                       uint32
	MaxColorAttachmentBytesPerSample          uint32
	MaxComputeWorkgroupStorageSize            uint32
	MaxComputeInvocationsPerWorkgroup         uint32
	MaxComputeWorkgroupSizeX                  uint32
	MaxComputeWorkgroupSizeY                  uint32
	MaxComputeWorkgroupSizeZ                  uint32
	MaxComputeWorkgroupsPerDimension          uint32
	MaxImmediateSize                          uint32
}

Limits contains device-level limits for various GPU capabilities, such as maximum texture dimensions and buffer sizes.

type LoadOp

type LoadOp uint32
const (
	LoadOpUndefined            LoadOp = 0
	LoadOpLoad                 LoadOp = 1
	LoadOpClear                LoadOp = 2
	LoadOpExpandResolveTexture LoadOp = 3
)

type MapAsyncStatus

type MapAsyncStatus uint32
const (
	MapAsyncStatusSuccess           MapAsyncStatus = 1
	MapAsyncStatusCallbackCancelled MapAsyncStatus = 2
	MapAsyncStatusError             MapAsyncStatus = 3
	MapAsyncStatusAborted           MapAsyncStatus = 4
)

type MapMode

type MapMode uint32
const (
	MapModeNone  MapMode = 0
	MapModeRead  MapMode = 1
	MapModeWrite MapMode = 2
)

type MipmapFilterMode

type MipmapFilterMode uint32
const (
	MipmapFilterModeUndefined MipmapFilterMode = 0
	MipmapFilterModeNearest   MipmapFilterMode = 1
	MipmapFilterModeLinear    MipmapFilterMode = 2
)

type MultisampleState

type MultisampleState struct {
	Count                  uint32
	Mask                   uint32
	AlphaToCoverageEnabled bool
}

MultisampleState describes multisampling settings for a render pipeline, including sample count, mask, and alpha-to-coverage.

type OptionalBool

type OptionalBool uint32
const (
	OptionalBoolFalse     OptionalBool = 0
	OptionalBoolTrue      OptionalBool = 1
	OptionalBoolUndefined OptionalBool = 2
)

type Origin3D

type Origin3D struct {
	X uint32
	Y uint32
	Z uint32
}

Origin3D defines a three-dimensional origin point, used for texture copy origins and viewport origins.

type PassTimestampWrites

type PassTimestampWrites struct {
	QuerySet                  *QuerySet
	BeginningOfPassWriteIndex uint32
	EndOfPassWriteIndex       uint32
}

PassTimestampWrites defines where to write timestamps in a render or compute pass.

type PipelineLayout

type PipelineLayout struct {
	// contains filtered or unexported fields
}

PipelineLayout represents a pipeline layout that defines the bind group layouts used by a pipeline. Pipeline layouts are created from a device and are used when creating pipelines.

func (*PipelineLayout) Release added in v0.0.11

func (p *PipelineLayout) Release()

Release releases the device and all associated resources. After calling this method, the device should no longer be used.

func (*PipelineLayout) SetLabel

func (p *PipelineLayout) SetLabel(label string)

SetLabel sets the debug label for the pipeline layout. This label appears in debuggers and validation layers.

type PipelineLayoutDescriptor

type PipelineLayoutDescriptor struct {
	Label            string
	BindGroupLayouts []*BindGroupLayout
	ImmediateSize    uint32
}

PipelineLayoutDescriptor describes a pipeline layout, which defines the bind group layouts used by a pipeline.

type PopErrorScopeCallback

type PopErrorScopeCallback func(typ ErrorType, message string)

PopErrorScopeCallback is called when popping an error scope from the error scope stack. The callback receives the error type and any error message.

type PowerPreference

type PowerPreference uint32
const (
	PowerPreferenceUndefined       PowerPreference = 0
	PowerPreferenceLowPower        PowerPreference = 1
	PowerPreferenceHighPerformance PowerPreference = 2
)

type PredefinedColorSpace

type PredefinedColorSpace uint32
const (
	PredefinedColorSpaceSRGB            PredefinedColorSpace = 1
	PredefinedColorSpaceDisplayP3       PredefinedColorSpace = 2
	PredefinedColorSpaceSRGBLinear      PredefinedColorSpace = 3
	PredefinedColorSpaceDisplayP3Linear PredefinedColorSpace = 4
)

type PresentMode

type PresentMode uint32
const (
	PresentModeUndefined   PresentMode = 0
	PresentModeFifo        PresentMode = 1
	PresentModeFifoRelaxed PresentMode = 2
	PresentModeImmediate   PresentMode = 3
	PresentModeMailbox     PresentMode = 4
)

func (PresentMode) String

func (p PresentMode) String() string

type PrimitiveState

type PrimitiveState struct {
	Topology         PrimitiveTopology
	StripIndexFormat IndexFormat
	FrontFace        FrontFace
	CullMode         CullMode
	UnclippedDepth   bool
}

PrimitiveState describes the primitive topology and rasterization settings for a render pipeline.

type PrimitiveTopology

type PrimitiveTopology uint32
const (
	PrimitiveTopologyUndefined     PrimitiveTopology = 0
	PrimitiveTopologyPointList     PrimitiveTopology = 1
	PrimitiveTopologyLineList      PrimitiveTopology = 2
	PrimitiveTopologyLineStrip     PrimitiveTopology = 3
	PrimitiveTopologyTriangleList  PrimitiveTopology = 4
	PrimitiveTopologyTriangleStrip PrimitiveTopology = 5
)

type QuerySet

type QuerySet struct {
	// contains filtered or unexported fields
}

QuerySet represents a query set that can be used to collect timestamp and occlusion query results. Query sets are created from a device and have a specific type and count.

func (*QuerySet) Destroy

func (q *QuerySet) Destroy()

Destroy destroys the query set and frees all associated GPU resources.

func (*QuerySet) GetCount

func (q *QuerySet) GetCount() uint32

GetCount returns the number of queries in the query set.

func (*QuerySet) GetType

func (q *QuerySet) GetType() QueryType

GetType returns the type of the query set (timestamp or occlusion).

func (*QuerySet) SetLabel

func (q *QuerySet) SetLabel(label string)

SetLabel sets the debug label for the query set. This label appears in debuggers and validation layers.

type QuerySetDescriptor

type QuerySetDescriptor struct {
	Label string
	Type  QueryType
	Count uint32
}

QuerySetDescriptor describes a query set, which is used to collect timestamp and occlusion query results.

type QueryType

type QueryType uint32
const (
	QueryTypeOcclusion QueryType = 1
	QueryTypeTimestamp QueryType = 2
)

type Queue

type Queue struct {
	// contains filtered or unexported fields
}

Queue represents a command queue that is used to submit commands to the GPU. Queues are obtained from a device and are used to execute command buffers.

func (*Queue) OnSubmittedWorkDone

func (q *Queue) OnSubmittedWorkDone(callback QueueWorkDoneCallback)

OnSubmittedWorkDone registers a callback that is called when all previously submitted commands complete. The callback is called when the GPU has finished executing all commands submitted up to this point.

func (*Queue) Release

func (q *Queue) Release()

Release releases the queue and all associated resources. After calling this method, the queue should no longer be used.

func (*Queue) SetLabel

func (q *Queue) SetLabel(label string)

SetLabel sets the debug label for the queue. This label appears in debuggers and validation layers.

func (*Queue) Submit

func (q *Queue) Submit(commands ...*CommandBuffer)

Submit submits command buffers to the queue for execution. The command buffers contain recorded commands that will be executed on the GPU.

func (*Queue) WriteBuffer

func (q *Queue) WriteBuffer(buffer *Buffer, offset uint64, data []byte)

WriteBuffer writes data from the CPU to a buffer on the GPU. The offset specifies where to start writing in the buffer.

func (*Queue) WriteTexture

func (q *Queue) WriteTexture(destination TexelCopyTextureInfo, data []byte, dataLayout TexelCopyBufferLayout, writeSize Extent3D)

WriteTexture writes data from the CPU to a texture on the GPU. The destination defines the texture region to write to, and the dataLayout defines the layout of the source data.

type QueueDescriptor

type QueueDescriptor struct {
	Label string
}

QueueDescriptor describes a queue, primarily for setting its label.

type QueueWorkDoneCallback

type QueueWorkDoneCallback func(status QueueWorkDoneStatus, message string)

QueueWorkDoneCallback is called when work submitted to a queue completes. The callback receives the status of the work and any error message.

type QueueWorkDoneCallbackInfo

type QueueWorkDoneCallbackInfo struct {
	Mode     callbackMode
	Callback QueueWorkDoneCallback
}

type QueueWorkDoneStatus

type QueueWorkDoneStatus uint32
const (
	QueueWorkDoneStatusSuccess           QueueWorkDoneStatus = 1
	QueueWorkDoneStatusCallbackCancelled QueueWorkDoneStatus = 2
	QueueWorkDoneStatusError             QueueWorkDoneStatus = 3
)

type RenderBundle

type RenderBundle struct {
	// contains filtered or unexported fields
}

RenderBundle represents a pre-recorded sequence of render commands that can be executed efficiently multiple times. Render bundles are created from a render bundle encoder and can be executed in render passes.

func (*RenderBundle) SetLabel

func (r *RenderBundle) SetLabel(label string)

SetLabel sets the debug label for the render bundle. This label appears in debuggers and validation layers.

type RenderBundleDescriptor

type RenderBundleDescriptor struct {
	Label string
}

RenderBundleDescriptor describes a render bundle, primarily for setting its label.

type RenderBundleEncoder

type RenderBundleEncoder struct {
	// contains filtered or unexported fields
}

RenderBundleEncoder encodes a sequence of render commands that can be recorded into a render bundle. Render bundle encoders are created from a device and are used to pre-record render commands.

func (*RenderBundleEncoder) Draw

func (r *RenderBundleEncoder) Draw(vertexCount uint32, instanceCount uint32, firstVertex uint32, firstInstance uint32)

Draw draws non-indexed primitives using the currently set pipeline and vertex buffers in the bundle. The vertexCount specifies the number of vertices to draw.

func (*RenderBundleEncoder) DrawIndexed

func (r *RenderBundleEncoder) DrawIndexed(indexCount uint32, instanceCount uint32, firstIndex uint32, baseVertex int32, firstInstance uint32)

DrawIndexed draws indexed primitives using the currently set pipeline, index buffer, and vertex buffers in the bundle. The indexCount specifies the number of indices to draw.

func (*RenderBundleEncoder) DrawIndexedIndirect

func (r *RenderBundleEncoder) DrawIndexedIndirect(indirectBuffer *Buffer, indirectOffset uint64)

DrawIndexedIndirect draws indexed primitives using parameters from a buffer in the bundle. The indirectBuffer contains the draw parameters and indirectOffset specifies the offset into that buffer.

func (*RenderBundleEncoder) DrawIndirect

func (r *RenderBundleEncoder) DrawIndirect(indirectBuffer *Buffer, indirectOffset uint64)

DrawIndirect draws primitives using parameters from a buffer in the bundle. The indirectBuffer contains the draw parameters and indirectOffset specifies the offset into that buffer.

func (*RenderBundleEncoder) Finish

Finish finishes recording and returns a render bundle. The descriptor can be used to set the label of the render bundle.

func (*RenderBundleEncoder) InsertDebugMarker

func (r *RenderBundleEncoder) InsertDebugMarker(markerLabel string)

InsertDebugMarker inserts a debug marker into the render bundle encoder. The marker label is used to identify the marker in debuggers and profilers.

func (*RenderBundleEncoder) PopDebugGroup

func (r *RenderBundleEncoder) PopDebugGroup()

PopDebugGroup pops the most recently pushed debug group from the render bundle encoder.

func (*RenderBundleEncoder) PushDebugGroup

func (r *RenderBundleEncoder) PushDebugGroup(groupLabel string)

PushDebugGroup pushes a debug group into the render bundle encoder with the given label. Debug groups can be nested and are used to group commands in debuggers and profilers.

func (*RenderBundleEncoder) SetBindGroup

func (r *RenderBundleEncoder) SetBindGroup(groupIndex uint32, group *BindGroup, dynamicOffsets []uint32)

SetBindGroup sets a bind group to be used for subsequent render commands in the bundle. The groupIndex specifies which bind group slot to use. The dynamicOffsets provide values for any dynamic buffer offsets in the bind group.

func (*RenderBundleEncoder) SetIndexBuffer

func (r *RenderBundleEncoder) SetIndexBuffer(buffer *Buffer, format IndexFormat, offset uint64, size uint64)

SetIndexBuffer sets an index buffer for subsequent indexed draw commands in the bundle. The format specifies the type of indices and the offset and size specify the region of the buffer to use.

func (*RenderBundleEncoder) SetLabel

func (r *RenderBundleEncoder) SetLabel(label string)

SetLabel sets the debug label for the render bundle encoder. This label appears in debuggers and validation layers.

func (*RenderBundleEncoder) SetPipeline

func (r *RenderBundleEncoder) SetPipeline(pipeline *RenderPipeline)

SetPipeline sets the render pipeline to be used for subsequent render commands in the bundle.

func (*RenderBundleEncoder) SetVertexBuffer

func (r *RenderBundleEncoder) SetVertexBuffer(slot uint32, buffer *Buffer, offset uint64, size uint64)

SetVertexBuffer sets a vertex buffer at the specified slot for subsequent draw commands in the bundle. The offset and size specify the region of the buffer to use.

type RenderBundleEncoderDescriptor

type RenderBundleEncoderDescriptor struct {
	Label              string
	ColorFormats       []TextureFormat
	DepthStencilFormat TextureFormat
	SampleCount        uint32
	DepthReadOnly      bool
	StencilReadOnly    bool
}

RenderBundleEncoderDescriptor describes a render bundle encoder, including color formats, depth stencil format, and sample count.

type RenderPassColorAttachment

type RenderPassColorAttachment struct {
	View          *TextureView
	DepthSlice    uint32
	ResolveTarget *TextureView
	LoadOp        LoadOp
	StoreOp       StoreOp
	ClearValue    Color
}

RenderPassColorAttachment describes a color attachment for a render pass, including the texture view, load/store operations, and clear value.

type RenderPassDepthStencilAttachment

type RenderPassDepthStencilAttachment struct {
	View              *TextureView
	DepthLoadOp       LoadOp
	DepthStoreOp      StoreOp
	DepthClearValue   float32
	DepthReadOnly     bool
	StencilLoadOp     LoadOp
	StencilStoreOp    StoreOp
	StencilClearValue uint32
	StencilReadOnly   bool
}

RenderPassDepthStencilAttachment describes a depth-stencil attachment for a render pass, including format, load/store operations, and clear values.

type RenderPassDescriptor

type RenderPassDescriptor struct {
	Label                  string
	ColorAttachments       []RenderPassColorAttachment
	DepthStencilAttachment *RenderPassDepthStencilAttachment
	OcclusionQuerySet      *QuerySet
	TimestampWrites        *PassTimestampWrites
}

RenderPassDescriptor describes a render pass, including label, color attachments, depth stencil attachment, and timestamp writes.

type RenderPassEncoder

type RenderPassEncoder struct {
	// contains filtered or unexported fields
}

RenderPassEncoder encodes render commands that will be drawn to a set of render targets. Render pass encoders are created from a command encoder and are used to issue rendering commands.

func (*RenderPassEncoder) BeginOcclusionQuery

func (r *RenderPassEncoder) BeginOcclusionQuery(queryIndex uint32)

BeginOcclusionQuery begins an occlusion query at the specified query index. Occlusion queries can be used to determine how many samples pass the depth test.

func (*RenderPassEncoder) Draw

func (r *RenderPassEncoder) Draw(vertexCount uint32, instanceCount uint32, firstVertex uint32, firstInstance uint32)

Draw draws non-indexed primitives using the currently set pipeline and vertex buffers. The vertexCount specifies the number of vertices to draw.

func (*RenderPassEncoder) DrawIndexed

func (r *RenderPassEncoder) DrawIndexed(indexCount uint32, instanceCount uint32, firstIndex uint32, baseVertex int32, firstInstance uint32)

DrawIndexed draws indexed primitives using the currently set pipeline, index buffer, and vertex buffers. The indexCount specifies the number of indices to draw.

func (*RenderPassEncoder) DrawIndexedIndirect

func (r *RenderPassEncoder) DrawIndexedIndirect(indirectBuffer *Buffer, indirectOffset uint64)

DrawIndexedIndirect draws indexed primitives using parameters from a buffer. The indirectBuffer contains the draw parameters and indirectOffset specifies the offset into that buffer.

func (*RenderPassEncoder) DrawIndirect

func (r *RenderPassEncoder) DrawIndirect(indirectBuffer *Buffer, indirectOffset uint64)

DrawIndirect draws primitives using parameters from a buffer. The indirectBuffer contains the draw parameters and indirectOffset specifies the offset into that buffer.

func (*RenderPassEncoder) End

func (r *RenderPassEncoder) End()

End ends the render pass. After calling this method, no more commands can be recorded in this pass.

func (*RenderPassEncoder) EndOcclusionQuery

func (r *RenderPassEncoder) EndOcclusionQuery()

EndOcclusionQuery ends the current occlusion query.

func (*RenderPassEncoder) ExecuteBundles

func (r *RenderPassEncoder) ExecuteBundles(bundles ...*RenderBundle)

ExecuteBundles executes a sequence of render bundles in the render pass. Render bundles are pre-recorded render commands that can be executed efficiently.

func (*RenderPassEncoder) InsertDebugMarker

func (r *RenderPassEncoder) InsertDebugMarker(markerLabel string)

InsertDebugMarker inserts a debug marker into the render pass. The marker label is used to identify the marker in debuggers and profilers.

func (*RenderPassEncoder) PopDebugGroup

func (r *RenderPassEncoder) PopDebugGroup()

PopDebugGroup pops the most recently pushed debug group from the render pass.

func (*RenderPassEncoder) PushDebugGroup

func (r *RenderPassEncoder) PushDebugGroup(groupLabel string)

PushDebugGroup pushes a debug group into the render pass with the given label. Debug groups can be nested and are used to group commands in debuggers and profilers.

func (*RenderPassEncoder) Release added in v0.0.11

func (r *RenderPassEncoder) Release()

Release releases the device and all associated resources. After calling this method, the device should no longer be used.

func (*RenderPassEncoder) SetBindGroup

func (r *RenderPassEncoder) SetBindGroup(groupIndex uint32, group *BindGroup, dynamicOffsets []uint32)

SetBindGroup sets a bind group to be used for subsequent render commands. The groupIndex specifies which bind group slot to use. The dynamicOffsets provide values for any dynamic buffer offsets in the bind group.

func (*RenderPassEncoder) SetBlendConstant

func (r *RenderPassEncoder) SetBlendConstant(color Color)

SetBlendConstant sets the blend constant color used for blend operations that use a constant color.

func (*RenderPassEncoder) SetIndexBuffer

func (r *RenderPassEncoder) SetIndexBuffer(buffer *Buffer, format IndexFormat, offset uint64, size uint64)

SetIndexBuffer sets an index buffer for subsequent indexed draw commands. The format specifies the type of indices and the offset and size specify the region of the buffer to use.

func (*RenderPassEncoder) SetLabel

func (r *RenderPassEncoder) SetLabel(label string)

SetLabel sets the debug label for the render pass encoder. This label appears in debuggers and validation layers.

func (*RenderPassEncoder) SetPipeline

func (r *RenderPassEncoder) SetPipeline(pipeline *RenderPipeline)

SetPipeline sets the render pipeline to be used for subsequent render commands.

func (*RenderPassEncoder) SetScissorRect

func (r *RenderPassEncoder) SetScissorRect(x uint32, y uint32, width uint32, height uint32)

SetScissorRect sets the scissor rectangle for subsequent render commands. Pixels outside this rectangle will be discarded.

func (*RenderPassEncoder) SetStencilReference

func (r *RenderPassEncoder) SetStencilReference(reference uint32)

SetStencilReference sets the stencil reference value for subsequent stencil operations.

func (*RenderPassEncoder) SetVertexBuffer

func (r *RenderPassEncoder) SetVertexBuffer(slot uint32, buffer *Buffer, offset uint64, size uint64)

SetVertexBuffer sets a vertex buffer at the specified slot for subsequent draw commands. The offset and size specify the region of the buffer to use.

func (*RenderPassEncoder) SetViewport

func (r *RenderPassEncoder) SetViewport(x float32, y float32, width float32, height float32, minDepth float32, maxDepth float32)

SetViewport sets the viewport for subsequent render commands. The viewport defines the region of the render target that output is drawn to.

type RenderPassMaxDrawCount

type RenderPassMaxDrawCount struct {
	MaxDrawCount uint64
}

RenderPassMaxDrawCount defines the maximum number of draws allowed in a render pass.

type RenderPipeline

type RenderPipeline struct {
	// contains filtered or unexported fields
}

RenderPipeline represents a render pipeline that defines how graphics are rendered. Render pipelines are created from a device and a render pipeline descriptor. They define the shader modules, vertex and fragment stages, and render state.

func (*RenderPipeline) GetBindGroupLayout

func (r *RenderPipeline) GetBindGroupLayout(groupIndex uint32) *BindGroupLayout

GetBindGroupLayout returns the bind group layout at the specified group index for this render pipeline. This layout defines the interface for bind groups used with this pipeline.

func (*RenderPipeline) Release

func (r *RenderPipeline) Release()

Release releases the render pipeline and all associated resources. After calling this method, the pipeline should no longer be used.

func (*RenderPipeline) SetLabel

func (r *RenderPipeline) SetLabel(label string)

SetLabel sets the debug label for the render pipeline. This label appears in debuggers and validation layers.

type RenderPipelineDescriptor

type RenderPipelineDescriptor struct {
	Label        string
	Layout       *PipelineLayout
	Vertex       VertexState
	Primitive    PrimitiveState
	DepthStencil *DepthStencilState
	Multisample  MultisampleState
	Fragment     *FragmentState
}

RenderPipelineDescriptor describes a render pipeline, including label, layout, vertex, primitive, depth stencil, multisample, and fragment states.

type RequestAdapterOptions

type RequestAdapterOptions struct {
	FeatureLevel         FeatureLevel
	PowerPreference      PowerPreference
	ForceFallbackAdapter bool
	BackendType          BackendType
	CompatibleSurface    *Surface
}

RequestAdapterOptions contains options for requesting an adapter, such as power preference and compatible surface.

type SType

type SType uint32
const (
	STypeShaderSourceSPIRV                 SType = 1
	STypeShaderSourceWGSL                  SType = 2
	STypeRenderPassMaxDrawCount            SType = 3
	STypeSurfaceSourceMetalLayer           SType = 4
	STypeSurfaceSourceWindowsHWND          SType = 5
	STypeSurfaceSourceXlibWindow           SType = 6
	STypeSurfaceSourceWaylandSurface       SType = 7
	STypeSurfaceSourceAndroidNativeWindow  SType = 8
	STypeSurfaceSourceXCBWindow            SType = 9
	STypeSurfaceColorManagement            SType = 10
	STypeRequestAdapterWebXROptions        SType = 11
	STypeTextureComponentSwizzleDescriptor SType = 12
	STypeExternalTextureBindingLayout      SType = 13
	STypeExternalTextureBindingEntry       SType = 14
	STypeCompatibilityModeLimits           SType = 15
	STypeTextureBindingViewDimension       SType = 16
)

type Sampler

type Sampler struct {
	// contains filtered or unexported fields
}

Sampler represents a sampler that defines how textures are sampled in shaders. Samplers are created from a device and define filtering modes, addressing modes, and other sampling parameters.

func (*Sampler) Release

func (s *Sampler) Release()

Release releases the sampler and all associated resources. After calling this method, the sampler should no longer be used.

func (*Sampler) SetLabel

func (s *Sampler) SetLabel(label string)

SetLabel sets the debug label for the sampler. This label appears in debuggers and validation layers.

type SamplerBindingLayout

type SamplerBindingLayout struct {
	Type SamplerBindingType
}

SamplerBindingLayout describes the layout for a sampler binding, including the sampler type.

type SamplerBindingType

type SamplerBindingType uint32
const (
	SamplerBindingTypeBindingNotUsed SamplerBindingType = 0
	SamplerBindingTypeUndefined      SamplerBindingType = 1
	SamplerBindingTypeFiltering      SamplerBindingType = 2
	SamplerBindingTypeNonFiltering   SamplerBindingType = 3
	SamplerBindingTypeComparison     SamplerBindingType = 4
)

type SamplerDescriptor

type SamplerDescriptor struct {
	Label         string
	AddressModeU  AddressMode
	AddressModeV  AddressMode
	AddressModeW  AddressMode
	MagFilter     FilterMode
	MinFilter     FilterMode
	MipmapFilter  MipmapFilterMode
	LodMinClamp   float32
	LodMaxClamp   float32
	Compare       CompareFunction
	MaxAnisotropy uint16
}

SamplerDescriptor describes a sampler, including addressing modes, filtering modes, and comparison function.

type ShaderModule

type ShaderModule struct {
	// contains filtered or unexported fields
}

ShaderModule represents a compiled shader module that can be used in GPU pipelines. Shader modules are created from WGSL or SPIR-V source code.

func (*ShaderModule) GetCompilationInfo

func (s *ShaderModule) GetCompilationInfo() []CompilationMessage

GetCompilationInfo returns compilation messages from the shader module compilation. Panics if the information cannot be retrieved.

func (*ShaderModule) Release

func (s *ShaderModule) Release()

Release releases the shader module and all associated resources. After calling this method, the module should no longer be used.

func (*ShaderModule) SetLabel

func (s *ShaderModule) SetLabel(label string)

SetLabel sets the debug label for the shader module. This label appears in debuggers and validation layers.

func (*ShaderModule) TryGetCompilationInfo

func (s *ShaderModule) TryGetCompilationInfo() ([]CompilationMessage, error)

TryGetCompilationInfo returns compilation messages from the shader module compilation, or an error if they cannot be retrieved.

type ShaderModuleDescriptor

type ShaderModuleDescriptor struct {
	Label string

	SPIRVSource *ShaderSourceSPIRV
	WGSLSource  *ShaderSourceWGSL
}

ShaderModuleDescriptor describes a shader module, which can contain either WGSL or SPIR-V source code.

type ShaderSourceSPIRV

type ShaderSourceSPIRV struct {
	Code []uint32
}

ShaderSourceSPIRV contains SPIR-V shader source code as a slice of uint32 words.

type ShaderSourceWGSL

type ShaderSourceWGSL struct {
	Code string
}

ShaderSourceWGSL contains WGSL (WebGPU Shading Language) shader source code as a string.

type ShaderStage

type ShaderStage uint32
const (
	ShaderStageNone     ShaderStage = 0
	ShaderStageVertex   ShaderStage = 1
	ShaderStageFragment ShaderStage = 2
	ShaderStageCompute  ShaderStage = 4
)

type StencilFaceState

type StencilFaceState struct {
	Compare     CompareFunction
	FailOp      StencilOperation
	DepthFailOp StencilOperation
	PassOp      StencilOperation
}

StencilFaceState describes the stencil state for a single face (front or back) of a depth-stencil attachment.

type StencilOperation

type StencilOperation uint32
const (
	StencilOperationUndefined      StencilOperation = 0
	StencilOperationKeep           StencilOperation = 1
	StencilOperationZero           StencilOperation = 2
	StencilOperationReplace        StencilOperation = 3
	StencilOperationInvert         StencilOperation = 4
	StencilOperationIncrementClamp StencilOperation = 5
	StencilOperationDecrementClamp StencilOperation = 6
	StencilOperationIncrementWrap  StencilOperation = 7
	StencilOperationDecrementWrap  StencilOperation = 8
)

type StorageTextureAccess

type StorageTextureAccess uint32
const (
	StorageTextureAccessBindingNotUsed StorageTextureAccess = 0
	StorageTextureAccessUndefined      StorageTextureAccess = 1
	StorageTextureAccessWriteOnly      StorageTextureAccess = 2
	StorageTextureAccessReadOnly       StorageTextureAccess = 3
	StorageTextureAccessReadWrite      StorageTextureAccess = 4
)

type StorageTextureBindingLayout

type StorageTextureBindingLayout struct {
	Access        StorageTextureAccess
	Format        TextureFormat
	ViewDimension TextureViewDimension
}

StorageTextureBindingLayout describes the layout for a storage texture binding, including access mode, format, and view dimension.

type StoreOp

type StoreOp uint32
const (
	StoreOpUndefined StoreOp = 0
	StoreOpStore     StoreOp = 1
	StoreOpDiscard   StoreOp = 2
)

type Surface

type Surface struct {
	// contains filtered or unexported fields
}

Surface represents a surface that can be used to present rendered graphics to a window. Surfaces are created from an instance and a platform-specific surface descriptor.

func (*Surface) Configure

func (s *Surface) Configure(config SurfaceConfiguration)

Configure configures the surface for rendering with the specified device and settings. The configuration defines the format, size, and present mode for the surface.

func (*Surface) GetCapabilities

func (s *Surface) GetCapabilities(adapter *Adapter) (SurfaceCapabilities, error)

GetCapabilities returns the capabilities of the surface when used with the given adapter. The capabilities include supported usages, formats, present modes, and alpha modes.

func (*Surface) GetCurrentTexture

func (s *Surface) GetCurrentTexture() *Texture

GetCurrentTexture obtains the current texture to render to from the surface. Panics if the texture cannot be obtained.

func (*Surface) Present

func (s *Surface) Present()

Present presents the current texture to the screen. Panics if presentation fails.

func (*Surface) Release

func (s *Surface) Release()

Release releases the surface and all associated resources. After calling this method, the surface should no longer be used.

func (*Surface) SetLabel

func (s *Surface) SetLabel(label string)

SetLabel sets the debug label for the surface. This label appears in debuggers and validation layers.

func (*Surface) TryGetCurrentTexture

func (s *Surface) TryGetCurrentTexture() (*Texture, error)

TryGetCurrentTexture obtains the current texture to render to from the surface, or returns an error if it cannot be obtained.

func (*Surface) TryPresent

func (s *Surface) TryPresent() error

TryPresent presents the current texture to the screen, returning an error if presentation fails.

func (*Surface) Unconfigure

func (s *Surface) Unconfigure()

Unconfigure unconfigures the surface, releasing any resources associated with it. After calling this method, the surface must be reconfigured before it can be used again.

type SurfaceCapabilities

type SurfaceCapabilities struct {
	Usages       TextureUsage
	Formats      []TextureFormat
	PresentModes []PresentMode
	AlphaModes   []CompositeAlphaMode
}

SurfaceCapabilities contains the capabilities of a surface, including supported usages, formats, present modes, and alpha modes.

type SurfaceColorManagement

type SurfaceColorManagement struct {
	ColorSpace      PredefinedColorSpace
	ToneMappingMode ToneMappingMode
}

SurfaceColorManagement defines color management settings for a surface, including color space and tone mapping mode.

type SurfaceConfiguration

type SurfaceConfiguration struct {
	Device      *Device
	Format      TextureFormat
	Usage       TextureUsage
	Width       uint32
	Height      uint32
	ViewFormats []TextureFormat
	AlphaMode   CompositeAlphaMode
	PresentMode PresentMode
}

SurfaceConfiguration configures a surface for rendering, including the device, format, usage, dimensions, and present mode.

type SurfaceDescriptor

type SurfaceDescriptor struct {
	Label          string
	MetalLayer     *SurfaceSourceMetalLayer
	WaylandSurface *SurfaceSourceWaylandSurface
	XlibWindow     *SurfaceSourceXlibWindow
	WindowsHWND    *SurfaceSourceWindowsHWND
	CanvasID       string // JS/WASM only: HTML canvas element ID
}

SurfaceDescriptor describes a surface, which can be created from various platform-specific sources like Metal layer, Windows HWND, or Wayland surface. When targeting WebAssembly/JS, set CanvasID to the HTML canvas element ID.

type SurfaceSourceMetalLayer

type SurfaceSourceMetalLayer struct {
	Layer unsafe.Pointer
}

SurfaceSourceMetalLayer contains a pointer to a Metal layer for creating a surface on macOS and iOS.

type SurfaceSourceWaylandSurface

type SurfaceSourceWaylandSurface struct {
	Display unsafe.Pointer
	Surface unsafe.Pointer
}

SurfaceSourceWaylandSurface contains pointers to a Wayland display and surface for creating a surface on Linux.

type SurfaceSourceWindowsHWND

type SurfaceSourceWindowsHWND struct {
	Hwnd      unsafe.Pointer
	Hinstance unsafe.Pointer
}

SurfaceSourceWindowsHWND contains window handle and instance for creating a surface on Windows.

type SurfaceSourceXlibWindow

type SurfaceSourceXlibWindow struct {
	Display unsafe.Pointer
	Window  uint64
}

SurfaceSourceXlibWindow contains display and window handles for creating a surface using Xlib on Linux.

type TexelCopyBufferInfo

type TexelCopyBufferInfo struct {
	Layout TexelCopyBufferLayout
	Buffer *Buffer
}

TexelCopyBufferInfo contains information about a buffer for texel copy operations, including layout and the buffer itself.

type TexelCopyBufferLayout

type TexelCopyBufferLayout struct {
	Offset       uint64
	BytesPerRow  uint32
	RowsPerImage uint32
}

TexelCopyBufferLayout defines the layout of data in a buffer for texel copy operations, including offset, bytes per row, and rows per image.

type TexelCopyTextureInfo

type TexelCopyTextureInfo struct {
	Texture  *Texture
	MipLevel uint32
	Origin   Origin3D
	Aspect   TextureAspect
}

TexelCopyTextureInfo contains information about a texture for texel copy operations, including the texture, mip level, origin, and aspect.

type Texture

type Texture struct {
	// contains filtered or unexported fields
}

Texture represents a GPU texture, which is a structured collection of pixels used for rendering and data storage. Textures are created from a device and can be used as render targets or sampled in shaders.

func (*Texture) AsImageCopy

func (t *Texture) AsImageCopy() TexelCopyTextureInfo

AsImageCopy returns a TexelCopyTextureInfo for use in image copy operations. The texture is treated as having all aspects, full mip levels, and the full extent.

func (*Texture) CreateView

func (t *Texture) CreateView(descriptor *TextureViewDescriptor) *TextureView

CreateView creates a texture view from this texture. Texture views can have different dimensions and mip level ranges than the underlying texture.

func (*Texture) Destroy

func (t *Texture) Destroy()

Destroy destroys the texture and frees all associated GPU resources.

func (*Texture) GetDepthOrArrayLayers

func (t *Texture) GetDepthOrArrayLayers() uint32

GetDepthOrArrayLayers returns the depth or array layer count of the texture. For 3D textures, this is the depth; for 2D array textures, this is the number of layers.

func (*Texture) GetDimension

func (t *Texture) GetDimension() TextureDimension

GetDimension returns the dimension of the texture (1D, 2D, or 3D).

func (*Texture) GetFormat

func (t *Texture) GetFormat() TextureFormat

GetFormat returns the pixel format of the texture.

func (*Texture) GetHeight

func (t *Texture) GetHeight() uint32

GetHeight returns the height of the texture in pixels.

func (*Texture) GetMipLevelCount

func (t *Texture) GetMipLevelCount() uint32

GetMipLevelCount returns the number of mip levels in the texture.

func (*Texture) GetSampleCount

func (t *Texture) GetSampleCount() uint32

GetSampleCount returns the sample count of the texture. A value of 1 means single-sampled; values greater than 1 indicate multisampling.

func (*Texture) GetTextureBindingViewDimension

func (t *Texture) GetTextureBindingViewDimension() TextureViewDimension

GetTextureBindingViewDimension returns the view dimension for texture binding. This is useful for determining how the texture can be sampled in shaders.

func (*Texture) GetUsage

func (t *Texture) GetUsage() TextureUsage

GetUsage returns the usage flags for the texture.

func (*Texture) GetWidth

func (t *Texture) GetWidth() uint32

GetWidth returns the width of the texture in pixels.

func (*Texture) SetLabel

func (t *Texture) SetLabel(label string)

SetLabel sets the debug label for the texture. This label appears in debuggers and validation layers.

type TextureAspect

type TextureAspect uint32
const (
	TextureAspectUndefined   TextureAspect = 0
	TextureAspectAll         TextureAspect = 1
	TextureAspectStencilOnly TextureAspect = 2
	TextureAspectDepthOnly   TextureAspect = 3
	TextureAspectPlane0Only  TextureAspect = 0
	TextureAspectPlane1Only  TextureAspect = 1
	TextureAspectPlane2Only  TextureAspect = 2
)

type TextureBindingLayout

type TextureBindingLayout struct {
	SampleType    TextureSampleType
	ViewDimension TextureViewDimension
	Multisampled  bool
}

TextureBindingLayout describes the layout for a texture binding, including sample type, view dimension, and whether it is multisampled.

type TextureBindingViewDimension

type TextureBindingViewDimension struct {
	TextureBindingViewDimension TextureViewDimension
}

TextureBindingViewDimension is used to specify the expected view dimension for a texture binding.

type TextureComponentSwizzle

type TextureComponentSwizzle struct {
	R ComponentSwizzle
	G ComponentSwizzle
	B ComponentSwizzle
	A ComponentSwizzle
}

TextureComponentSwizzle describes how to swizzle the components of a texture view.

type TextureComponentSwizzleDescriptor

type TextureComponentSwizzleDescriptor struct {
	Swizzle TextureComponentSwizzle
}

TextureComponentSwizzleDescriptor describes a swizzle to be applied to a texture view.

type TextureDescriptor

type TextureDescriptor struct {
	Label         string
	Usage         TextureUsage
	Dimension     TextureDimension
	Size          Extent3D
	Format        TextureFormat
	MipLevelCount uint32
	SampleCount   uint32
	ViewFormats   []TextureFormat
}

TextureDescriptor describes a texture, including its dimensions, format, usage, mip level count, and sample count.

type TextureDimension

type TextureDimension uint32
const (
	TextureDimensionUndefined TextureDimension = 0
	TextureDimension1D        TextureDimension = 1
	TextureDimension2D        TextureDimension = 2
	TextureDimension3D        TextureDimension = 3
)

type TextureFormat

type TextureFormat uint32
const (
	TextureFormatUndefined            TextureFormat = 0
	TextureFormatR8Unorm              TextureFormat = 1
	TextureFormatR8Snorm              TextureFormat = 2
	TextureFormatR8Uint               TextureFormat = 3
	TextureFormatR8Sint               TextureFormat = 4
	TextureFormatR16Unorm             TextureFormat = 5
	TextureFormatR16Snorm             TextureFormat = 6
	TextureFormatR16Uint              TextureFormat = 7
	TextureFormatR16Sint              TextureFormat = 8
	TextureFormatR16Float             TextureFormat = 9
	TextureFormatRG8Unorm             TextureFormat = 10
	TextureFormatRG8Snorm             TextureFormat = 11
	TextureFormatRG8Uint              TextureFormat = 12
	TextureFormatRG8Sint              TextureFormat = 13
	TextureFormatR32Float             TextureFormat = 14
	TextureFormatR32Uint              TextureFormat = 15
	TextureFormatR32Sint              TextureFormat = 16
	TextureFormatRG16Unorm            TextureFormat = 17
	TextureFormatRG16Snorm            TextureFormat = 18
	TextureFormatRG16Uint             TextureFormat = 19
	TextureFormatRG16Sint             TextureFormat = 20
	TextureFormatRG16Float            TextureFormat = 21
	TextureFormatRGBA8Unorm           TextureFormat = 22
	TextureFormatRGBA8UnormSRGB       TextureFormat = 23
	TextureFormatRGBA8Snorm           TextureFormat = 24
	TextureFormatRGBA8Uint            TextureFormat = 25
	TextureFormatRGBA8Sint            TextureFormat = 26
	TextureFormatBGRA8Unorm           TextureFormat = 27
	TextureFormatBGRA8UnormSRGB       TextureFormat = 28
	TextureFormatRGB10A2Uint          TextureFormat = 29
	TextureFormatRGB10A2Unorm         TextureFormat = 30
	TextureFormatRG11B10Ufloat        TextureFormat = 31
	TextureFormatRGB9E5Ufloat         TextureFormat = 32
	TextureFormatRG32Float            TextureFormat = 33
	TextureFormatRG32Uint             TextureFormat = 34
	TextureFormatRG32Sint             TextureFormat = 35
	TextureFormatRGBA16Unorm          TextureFormat = 36
	TextureFormatRGBA16Snorm          TextureFormat = 37
	TextureFormatRGBA16Uint           TextureFormat = 38
	TextureFormatRGBA16Sint           TextureFormat = 39
	TextureFormatRGBA16Float          TextureFormat = 40
	TextureFormatRGBA32Float          TextureFormat = 41
	TextureFormatRGBA32Uint           TextureFormat = 42
	TextureFormatRGBA32Sint           TextureFormat = 43
	TextureFormatStencil8             TextureFormat = 44
	TextureFormatDepth16Unorm         TextureFormat = 45
	TextureFormatDepth24Plus          TextureFormat = 46
	TextureFormatDepth24PlusStencil8  TextureFormat = 47
	TextureFormatDepth32Float         TextureFormat = 48
	TextureFormatDepth32FloatStencil8 TextureFormat = 49
	TextureFormatBC1RGBAUnorm         TextureFormat = 50
	TextureFormatBC1RGBAUnormSRGB     TextureFormat = 51
	TextureFormatBC2RGBAUnorm         TextureFormat = 52
	TextureFormatBC2RGBAUnormSRGB     TextureFormat = 53
	TextureFormatBC3RGBAUnorm         TextureFormat = 54
	TextureFormatBC3RGBAUnormSRGB     TextureFormat = 55
	TextureFormatBC4RUnorm            TextureFormat = 56
	TextureFormatBC4RSnorm            TextureFormat = 57
	TextureFormatBC5RGUnorm           TextureFormat = 58
	TextureFormatBC5RGSnorm           TextureFormat = 59
	TextureFormatBC6HRGBUfloat        TextureFormat = 60
	TextureFormatBC6HRGBFloat         TextureFormat = 61
	TextureFormatBC7RGBAUnorm         TextureFormat = 62
	TextureFormatBC7RGBAUnormSRGB     TextureFormat = 63
	TextureFormatETC2RGB8Unorm        TextureFormat = 64
	TextureFormatETC2RGB8UnormSRGB    TextureFormat = 65
	TextureFormatETC2RGB8A1Unorm      TextureFormat = 66
	TextureFormatETC2RGB8A1UnormSRGB  TextureFormat = 67
	TextureFormatETC2RGBA8Unorm       TextureFormat = 68
	TextureFormatETC2RGBA8UnormSRGB   TextureFormat = 69
	TextureFormatEACR11Unorm          TextureFormat = 70
	TextureFormatEACR11Snorm          TextureFormat = 71
	TextureFormatEACRG11Unorm         TextureFormat = 72
	TextureFormatEACRG11Snorm         TextureFormat = 73
	TextureFormatASTC4x4Unorm         TextureFormat = 74
	TextureFormatASTC4x4UnormSRGB     TextureFormat = 75
	TextureFormatASTC5x4Unorm         TextureFormat = 76
	TextureFormatASTC5x4UnormSRGB     TextureFormat = 77
	TextureFormatASTC5x5Unorm         TextureFormat = 78
	TextureFormatASTC5x5UnormSRGB     TextureFormat = 79
	TextureFormatASTC6x5Unorm         TextureFormat = 80
	TextureFormatASTC6x5UnormSRGB     TextureFormat = 81
	TextureFormatASTC6x6Unorm         TextureFormat = 82
	TextureFormatASTC6x6UnormSRGB     TextureFormat = 83
	TextureFormatASTC8x5Unorm         TextureFormat = 84
	TextureFormatASTC8x5UnormSRGB     TextureFormat = 85
	TextureFormatASTC8x6Unorm         TextureFormat = 86
	TextureFormatASTC8x6UnormSRGB     TextureFormat = 87
	TextureFormatASTC8x8Unorm         TextureFormat = 88
	TextureFormatASTC8x8UnormSRGB     TextureFormat = 89
	TextureFormatASTC10x5Unorm        TextureFormat = 90
	TextureFormatASTC10x5UnormSRGB    TextureFormat = 91
	TextureFormatASTC10x6Unorm        TextureFormat = 92
	TextureFormatASTC10x6UnormSRGB    TextureFormat = 93
	TextureFormatASTC10x8Unorm        TextureFormat = 94
	TextureFormatASTC10x8UnormSRGB    TextureFormat = 95
	TextureFormatASTC10x10Unorm       TextureFormat = 96
	TextureFormatASTC10x10UnormSRGB   TextureFormat = 97
	TextureFormatASTC12x10Unorm       TextureFormat = 98
	TextureFormatASTC12x10UnormSRGB   TextureFormat = 99
	TextureFormatASTC12x12Unorm       TextureFormat = 100
	TextureFormatASTC12x12UnormSRGB   TextureFormat = 101
)

func (TextureFormat) String

func (t TextureFormat) String() string

type TextureSampleType

type TextureSampleType uint32
const (
	TextureSampleTypeBindingNotUsed    TextureSampleType = 0
	TextureSampleTypeUndefined         TextureSampleType = 1
	TextureSampleTypeFloat             TextureSampleType = 2
	TextureSampleTypeUnfilterableFloat TextureSampleType = 3
	TextureSampleTypeDepth             TextureSampleType = 4
	TextureSampleTypeSint              TextureSampleType = 5
	TextureSampleTypeUint              TextureSampleType = 6
)

type TextureUsage

type TextureUsage uint32
const (
	TextureUsageNone                TextureUsage = 0
	TextureUsageCopySrc             TextureUsage = 1
	TextureUsageCopyDst             TextureUsage = 2
	TextureUsageTextureBinding      TextureUsage = 4
	TextureUsageStorageBinding      TextureUsage = 8
	TextureUsageRenderAttachment    TextureUsage = 16
	TextureUsageTransientAttachment TextureUsage = 32
	TextureUsageStorageAttachment   TextureUsage = 64
)

type TextureView

type TextureView struct {
	// contains filtered or unexported fields
}

TextureView represents a view of a texture with specific dimensions, mip levels, and array layers. Texture views are created from textures and can be used as render targets or sampled in shaders.

func (*TextureView) Release

func (t *TextureView) Release()

Release releases the texture view and all associated resources. After calling this method, the view should no longer be used.

func (*TextureView) SetLabel

func (t *TextureView) SetLabel(label string)

SetLabel sets the debug label for the texture view. This label appears in debuggers and validation layers.

type TextureViewDescriptor

type TextureViewDescriptor struct {
	Label           string
	Format          TextureFormat
	Dimension       TextureViewDimension
	BaseMipLevel    uint32
	MipLevelCount   uint32
	BaseArrayLayer  uint32
	ArrayLayerCount uint32
	Aspect          TextureAspect
	Usage           TextureUsage
}

TextureViewDescriptor describes a texture view, including format, dimension, mip level range, array layer range, and aspect.

type TextureViewDimension

type TextureViewDimension uint32
const (
	TextureViewDimensionUndefined TextureViewDimension = 0
	TextureViewDimension1D        TextureViewDimension = 1
	TextureViewDimension2D        TextureViewDimension = 2
	TextureViewDimension2DArray   TextureViewDimension = 3
	TextureViewDimensionCube      TextureViewDimension = 4
	TextureViewDimensionCubeArray TextureViewDimension = 5
	TextureViewDimension3D        TextureViewDimension = 6
)

type ToneMappingMode

type ToneMappingMode uint32
const (
	ToneMappingModeStandard ToneMappingMode = 1
	ToneMappingModeExtended ToneMappingMode = 2
)

type UncapturedErrorCallback

type UncapturedErrorCallback func(device *Device, typ ErrorType, message string)

UncapturedErrorCallback is called when an uncaptured error occurs on a device. The callback receives the device, the error type, and the error message.

type UncapturedErrorCallbackInfo

type UncapturedErrorCallbackInfo struct {
	Callback UncapturedErrorCallback
}

type VertexAttribute

type VertexAttribute struct {
	Format         VertexFormat
	Offset         uint64
	ShaderLocation uint32
}

VertexAttribute describes a vertex attribute, including format, offset, and shader location.

type VertexBufferLayout

type VertexBufferLayout struct {
	StepMode    VertexStepMode
	ArrayStride uint64
	Attributes  []VertexAttribute
}

VertexBufferLayout describes the layout of a vertex buffer, including step mode, array stride, and attributes.

type VertexFormat

type VertexFormat uint32
const (
	VertexFormatUint8           VertexFormat = 1
	VertexFormatUint8x2         VertexFormat = 2
	VertexFormatUint8x4         VertexFormat = 3
	VertexFormatSint8           VertexFormat = 4
	VertexFormatSint8x2         VertexFormat = 5
	VertexFormatSint8x4         VertexFormat = 6
	VertexFormatUnorm8          VertexFormat = 7
	VertexFormatUnorm8x2        VertexFormat = 8
	VertexFormatUnorm8x4        VertexFormat = 9
	VertexFormatSnorm8          VertexFormat = 10
	VertexFormatSnorm8x2        VertexFormat = 11
	VertexFormatSnorm8x4        VertexFormat = 12
	VertexFormatUint16          VertexFormat = 13
	VertexFormatUint16x2        VertexFormat = 14
	VertexFormatUint16x4        VertexFormat = 15
	VertexFormatSint16          VertexFormat = 16
	VertexFormatSint16x2        VertexFormat = 17
	VertexFormatSint16x4        VertexFormat = 18
	VertexFormatUnorm16         VertexFormat = 19
	VertexFormatUnorm16x2       VertexFormat = 20
	VertexFormatUnorm16x4       VertexFormat = 21
	VertexFormatSnorm16         VertexFormat = 22
	VertexFormatSnorm16x2       VertexFormat = 23
	VertexFormatSnorm16x4       VertexFormat = 24
	VertexFormatFloat16         VertexFormat = 25
	VertexFormatFloat16x2       VertexFormat = 26
	VertexFormatFloat16x4       VertexFormat = 27
	VertexFormatFloat32         VertexFormat = 28
	VertexFormatFloat32x2       VertexFormat = 29
	VertexFormatFloat32x3       VertexFormat = 30
	VertexFormatFloat32x4       VertexFormat = 31
	VertexFormatUint32          VertexFormat = 32
	VertexFormatUint32x2        VertexFormat = 33
	VertexFormatUint32x3        VertexFormat = 34
	VertexFormatUint32x4        VertexFormat = 35
	VertexFormatSint32          VertexFormat = 36
	VertexFormatSint32x2        VertexFormat = 37
	VertexFormatSint32x3        VertexFormat = 38
	VertexFormatSint32x4        VertexFormat = 39
	VertexFormatUnorm10_10_10_2 VertexFormat = 40
	VertexFormatUnorm8x4BGRA    VertexFormat = 41
)

func (VertexFormat) Size

func (f VertexFormat) Size() int

type VertexState

type VertexState struct {
	Module     *ShaderModule
	EntryPoint string
	Constants  map[string]float64
	Buffers    []VertexBufferLayout
}

VertexState describes the vertex stage of a render pipeline, including shader module, entry point, constants, and buffer layouts.

type VertexStepMode

type VertexStepMode uint32
const (
	VertexStepModeUndefined VertexStepMode = 0
	VertexStepModeVertex    VertexStepMode = 1
	VertexStepModeInstance  VertexStepMode = 2
)

type WGSLLanguageFeatureName

type WGSLLanguageFeatureName uint32
const (
	WGSLLanguageFeatureNameReadonlyAndReadwriteStorageTextures WGSLLanguageFeatureName = 1
	WGSLLanguageFeatureNamePacked4x8IntegerDotProduct          WGSLLanguageFeatureName = 2
	WGSLLanguageFeatureNameUnrestrictedPointerParameters       WGSLLanguageFeatureName = 3
	WGSLLanguageFeatureNamePointerCompositeAccess              WGSLLanguageFeatureName = 4
	WGSLLanguageFeatureNameUniformBufferStandardLayout         WGSLLanguageFeatureName = 5
	WGSLLanguageFeatureNameSubgroupId                          WGSLLanguageFeatureName = 6
	WGSLLanguageFeatureNameTextureAndSamplerLet                WGSLLanguageFeatureName = 7
	WGSLLanguageFeatureNameSubgroupUniformity                  WGSLLanguageFeatureName = 8
	WGSLLanguageFeatureNameTextureFormatsTier1                 WGSLLanguageFeatureName = 9
)

func (WGSLLanguageFeatureName) String

func (f WGSLLanguageFeatureName) String() string

Directories

Path Synopsis

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL