gputypes

package module
v0.8.0 Latest Latest
Warning

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

Go to latest
Published: Aug 31, 2026 License: MIT Imports: 1 Imported by: 38

README

gputypes

WebGPU type definitions for the gogpu ecosystem.

Overview

gputypes provides all WebGPU enums, structs, and constants as pure Go types with zero dependencies. It serves as the single source of truth for WebGPU types across the entire ecosystem.

Installation

go get github.com/gogpu/gputypes

Requires: Go 1.25+

Why gputypes?

The Problem: Type Incompatibility

Without a shared types package, each project defines its own types:

// Different projects, incompatible types!
wgpu.TextureFormat        // wgpu's type
webgpu.TextureFormat      // go-webgpu's type
born.TextureFormat        // born-ml's type

// User must convert everywhere - painful!
format := wgpu.TextureFormat(webgpuFormat)
The Solution: Shared Types

With gputypes, all projects use the same types:

import "github.com/gogpu/gputypes"

// All projects use gputypes.TextureFormat
// Types are directly compatible - no conversion needed!

Architecture

                    gputypes (ZERO deps)
                 All WebGPU types (100+)
                           │
         ┌─────────────────┼─────────────────┐
         │                 │                 │
         ▼                 ▼                 ▼
    gpucontext          wgpu          go-webgpu/webgpu
  (imports gputypes)  (imports)         (imports)
         │                 │                 │
         └────────┬────────┴────────┬────────┘
                  │                 │
                  ▼                 ▼
               gogpu             born-ml

Types

Based on WebGPU spec and wgpu-types:

Texture & Sampler
  • TextureFormat (97 formats including BC, ETC2, ASTC compressed)
  • TextureUsage, TextureDimension, TextureViewDimension, TextureAspect
  • TextureDescriptor, TextureViewDescriptor, TextureSampleType
  • AddressMode, FilterMode, MipmapFilterMode, CompareFunction
  • SamplerDescriptor, SamplerBindingType
Buffer & Binding
  • BufferUsage, BufferBindingType, BufferMapState, MapMode
  • BufferDescriptor, IndexFormat
  • BindGroupLayoutEntry, BindGroupEntry, BindingResource
  • BufferBindingLayout, SamplerBindingLayout, TextureBindingLayout
  • StorageTextureBindingLayout, PipelineLayoutDescriptor
Shader
  • ShaderStage flags (Vertex, Fragment, Compute)
  • ShaderModuleDescriptor, ShaderSource (WGSL, SPIR-V, GLSL)
  • ProgrammableStage
Pipeline
  • PrimitiveTopology, FrontFace, CullMode, PrimitiveState — zero value of each enum is the WebGPU spec default (TriangleList, CCW, None), so PrimitiveState{} is a valid spec-default configuration
  • BlendState, BlendFactor, BlendOperation, BlendComponent
  • DepthStencilState, StencilOperation, StencilFaceState
  • MultisampleState, ColorTargetState, ColorWriteMask
Vertex
  • VertexFormat (31 formats)
  • VertexStepMode, VertexAttribute, VertexBufferLayout
  • VertexState, FragmentState
Render Pass
  • LoadOp, StoreOp
  • RenderPassColorAttachment, RenderPassDepthStencilAttachment
  • RenderPassDescriptor
Adapter & Device
  • DeviceType, Backend, Backends
  • AdapterInfo, PowerPreference, MemoryHints
  • DeviceDescriptor, RequestAdapterOptions
  • InstanceDescriptor, InstanceFlags
  • Dx12ShaderCompiler, GLBackend
Limits & Features
  • Limits struct with all WebGPU limits (38+ fields, including 8 RT limits)
  • Features flags (25 optional capabilities, including 5 RT features)
  • DefaultLimits(), DownlevelLimits() helpers
Ray Tracing (experimental)
  • AccelerationStructureFlags, AccelerationStructureGeometryFlags bitflags
  • BlasTriangleGeometrySizeDescriptor, BlasAABBGeometrySizeDescriptor
  • CreateBlasDescriptor, CreateTlasDescriptor
  • AccelerationStructureBindingLayout, AccelerationStructureUpdateMode, AccelerationStructureCopyMode
  • BufferUsageAccelerationStructureScratch, BufferUsageBlasInput, BufferUsageTlasInput
  • Feature-gated: requires FeatureRayQuery on the device
Surface
  • PresentMode (AutoVsync, Fifo, Immediate, Mailbox)
  • CompositeAlphaMode (Auto, Opaque, PreMultiplied, etc.)
  • SurfaceConfiguration, SurfaceCapabilities, SurfaceStatus
Copy Operations
  • ImageSubresourceRange (for partial texture operations)
  • TextureDataLayout, ImageCopyTexture
Geometry & Color
  • Extent3D, Origin3D
  • Color (RGBA float64) with predefined colors

Relationship to gpucontext

Package Purpose Dependencies
gputypes Data types (enums, structs, constants) ZERO
gpucontext Interfaces (DeviceProvider, EventSource, Texture) imports gputypes
Why Two Packages?
Aspect gputypes gpucontext
Responsibility Data definitions Behavioral contracts
Change frequency Rare (WebGPU spec is stable) Medium (API evolution)
Size Large (100+ types) Small (10-15 interfaces)

Principle: Separation of data types from behavioral interfaces.

Why gpucontext imports gputypes?

Interfaces need types in their signatures:

// gpucontext needs gputypes for type-safe interfaces
type DeviceProvider interface {
    SurfaceFormat() gputypes.TextureFormat  // ← uses gputypes
}

type Texture interface {
    Format() gputypes.TextureFormat  // ← uses gputypes
}

This ensures type compatibility across all implementations.

Ecosystem

Package Description Uses gputypes
gogpu/gogpu Graphics framework
gogpu/wgpu Pure Go WebGPU
gogpu/gg 2D graphics library ✅ (via gpucontext)
gogpu/gpucontext Shared interfaces ✅ (imports)
go-webgpu/webgpu Rust FFI bindings
born-ml/born ML framework

Comparison with Rust

Rust Go (gogpu) Purpose
wgpu-types gputypes WebGPU type definitions
gpucontext Integration interfaces (Go-specific)
wgpu-core wgpu/core WebGPU implementation
wgpu-hal wgpu/hal Hardware abstraction

Status

See CHANGELOG.md for version history and ROADMAP.md for upcoming plans.

License

MIT License — see LICENSE for details.


Part of the gogpu ecosystem — Pure Go GPU Computing.

Documentation

Overview

Package gputypes provides WebGPU type definitions for the gogpu ecosystem.

gputypes is the single source of truth for WebGPU types, providing all enums, structs, and constants used across the ecosystem. It has ZERO external dependencies, making it the foundation package that all other packages can safely import.

Architecture

gputypes sits at the bottom of the dependency graph:

              gputypes (zero deps)
                     │
     ┌───────────────┼───────────────┐
     ▼               ▼               ▼
gpucontext         wgpu       go-webgpu/webgpu
     │               │               │
     └───────┬───────┴───────┬───────┘
             ▼               ▼
          gogpu           born-ml

Type Categories

The package provides types in several categories:

Texture types: TextureFormat, TextureUsage, TextureDimension, TextureDescriptor, etc.

Buffer types: BufferUsage, BufferDescriptor, IndexFormat, etc.

Sampler types: AddressMode, FilterMode, CompareFunction, SamplerDescriptor, etc.

Render types: BlendState, BlendFactor, BlendOperation, PrimitiveTopology, etc.

Shader types: ShaderStage, ShaderModuleDescriptor, etc.

Vertex types: VertexFormat, VertexStepMode, VertexAttribute, etc.

Binding types: BindGroupLayoutEntry, BufferBindingLayout, TextureBindingLayout, etc.

Adapter types: DeviceType, AdapterInfo, PowerPreference, Backend, etc.

Limits and Features: Limits struct, Features flags, etc.

Geometry types: Extent3D, Origin3D, Color, etc.

Ray Tracing types (experimental): AccelerationStructureFlags, BlasTriangleGeometrySizeDescriptor, CreateBlasDescriptor, CreateTlasDescriptor, AccelerationStructureBindingLayout, etc.

Usage

Import the package and use types directly:

import "github.com/gogpu/gputypes"

format := gputypes.TextureFormatRGBA8Unorm
usage := gputypes.TextureUsageCopySrc | gputypes.TextureUsageRenderAttachment

desc := gputypes.TextureDescriptor{
    Size:   gputypes.Extent3D{Width: 800, Height: 600, DepthOrArrayLayers: 1},
    Format: format,
    Usage:  usage,
}

WebGPU Specification

Types follow the W3C WebGPU specification: https://www.w3.org/TR/webgpu/

Naming conventions follow wgpu-types (Rust) where applicable: https://docs.rs/wgpu-types

Index

Constants

View Source
const (
	// AABBGeometryMinStride is the minimum stride for AABB geometry data (two vec3<f32> = 24 bytes).
	AABBGeometryMinStride uint64 = 24
	// TransformBufferAlignment is the required alignment for transform buffers in BLAS builds.
	TransformBufferAlignment uint64 = 16
	// InstanceBufferAlignment is the required alignment for instance buffers in TLAS builds.
	InstanceBufferAlignment uint64 = 16
)
View Source
const (
	// ShaderStagesVertexFragment includes vertex and fragment stages.
	ShaderStagesVertexFragment = ShaderStageVertex | ShaderStageFragment
	// ShaderStagesAll includes all stages (vertex, fragment, and compute).
	ShaderStagesAll = ShaderStageVertex | ShaderStageFragment | ShaderStageCompute
)

Common shader stage combinations.

Variables

View Source
var (
	// ColorTransparent is fully transparent black.
	ColorTransparent = Color{R: 0, G: 0, B: 0, A: 0}
	// ColorBlack is opaque black.
	ColorBlack = Color{R: 0, G: 0, B: 0, A: 1}
	// ColorWhite is opaque white.
	ColorWhite = Color{R: 1, G: 1, B: 1, A: 1}
	// ColorRed is opaque red.
	ColorRed = Color{R: 1, G: 0, B: 0, A: 1}
	// ColorGreen is opaque green.
	ColorGreen = Color{R: 0, G: 1, B: 0, A: 1}
	// ColorBlue is opaque blue.
	ColorBlue = Color{R: 0, G: 0, B: 1, A: 1}
	// ColorYellow is opaque yellow.
	ColorYellow = Color{R: 1, G: 1, B: 0, A: 1}
	// ColorCyan is opaque cyan.
	ColorCyan = Color{R: 0, G: 1, B: 1, A: 1}
	// ColorMagenta is opaque magenta.
	ColorMagenta = Color{R: 1, G: 0, B: 1, A: 1}
	// ColorGray is opaque 50% gray.
	ColorGray = Color{R: 0.5, G: 0.5, B: 0.5, A: 1}
)

Predefined colors for common use cases.

View Source
var OriginZero = Origin3D{X: 0, Y: 0, Z: 0}

OriginZero is the origin at (0, 0, 0).

Functions

This section is empty.

Types

type AccelerationStructureBindingLayout added in v0.6.0

type AccelerationStructureBindingLayout struct {
	// VertexReturn enables triangle vertex data retrieval on ray hit.
	// Requires FeatureRayHitVertexReturn.
	VertexReturn bool
}

AccelerationStructureBindingLayout describes an acceleration structure binding in a bind group layout.

type AccelerationStructureCopyMode added in v0.6.0

type AccelerationStructureCopyMode uint8

AccelerationStructureCopyMode determines the type of copy operation.

const (
	// AccelerationStructureCopyModeClone creates a direct duplicate.
	AccelerationStructureCopyModeClone AccelerationStructureCopyMode = iota
	// AccelerationStructureCopyModeCompact duplicates and compacts (20-40% memory reduction).
	AccelerationStructureCopyModeCompact
)

type AccelerationStructureFlags added in v0.6.0

type AccelerationStructureFlags uint8

AccelerationStructureFlags are optional flags for acceleration structure creation.

const (
	// ASFlagAllowUpdate enables incremental updates after initial build.
	ASFlagAllowUpdate AccelerationStructureFlags = 0x01
	// ASFlagAllowCompaction enables compaction via copy operation.
	ASFlagAllowCompaction AccelerationStructureFlags = 0x02
	// ASFlagPreferFastTrace optimizes for trace performance (static geometry).
	ASFlagPreferFastTrace AccelerationStructureFlags = 0x04
	// ASFlagPreferFastBuild optimizes for build performance (dynamic geometry).
	ASFlagPreferFastBuild AccelerationStructureFlags = 0x08
	// ASFlagLowMemory optimizes for low memory usage.
	ASFlagLowMemory AccelerationStructureFlags = 0x10
	// ASFlagUseTransform enables the transform buffer in BLAS triangle builds.
	ASFlagUseTransform AccelerationStructureFlags = 0x20
	// ASFlagAllowRayHitVertexReturn enables triangle vertex retrieval on ray hit.
	ASFlagAllowRayHitVertexReturn AccelerationStructureFlags = 0x40
)

func (AccelerationStructureFlags) Contains added in v0.6.0

Contains returns true if all flags in other are set.

type AccelerationStructureGeometryFlags added in v0.6.0

type AccelerationStructureGeometryFlags uint8

AccelerationStructureGeometryFlags are per-geometry flags.

const (
	// ASGeometryFlagOpaque marks geometry as opaque (skips any-hit shader).
	ASGeometryFlagOpaque AccelerationStructureGeometryFlags = 0x01
	// ASGeometryFlagNoDuplicateAnyHitInvocation limits any-hit to one invocation per primitive.
	ASGeometryFlagNoDuplicateAnyHitInvocation AccelerationStructureGeometryFlags = 0x02
)

func (AccelerationStructureGeometryFlags) Contains added in v0.6.0

Contains returns true if all flags in other are set.

type AccelerationStructureType added in v0.6.0

type AccelerationStructureType uint8

AccelerationStructureType describes what kind of primitives an acceleration structure contains.

const (
	// AccelerationStructureTypeTriangles contains triangle geometry.
	AccelerationStructureTypeTriangles AccelerationStructureType = iota
	// AccelerationStructureTypeAABBs contains axis-aligned bounding boxes.
	AccelerationStructureTypeAABBs
	// AccelerationStructureTypeInstances contains TLAS instance references to BLASes.
	AccelerationStructureTypeInstances
)

type AccelerationStructureUpdateMode added in v0.6.0

type AccelerationStructureUpdateMode uint8

AccelerationStructureUpdateMode determines how an acceleration structure is updated.

const (
	// AccelerationStructureUpdateModeBuild always performs a full build.
	AccelerationStructureUpdateModeBuild AccelerationStructureUpdateMode = iota
	// AccelerationStructureUpdateModePreferUpdate performs an incremental update
	// if the hardware supports it (e.g. for skinned meshes), otherwise falls back to full build.
	AccelerationStructureUpdateModePreferUpdate
)

type AdapterInfo

type AdapterInfo struct {
	// Name is the human-readable name of the adapter (e.g., "NVIDIA GeForce RTX 4090").
	Name string
	// Vendor is the adapter vendor name (e.g., "NVIDIA", "AMD", "Intel").
	Vendor string
	// VendorID is the PCI vendor ID.
	VendorID uint32
	// DeviceID is the PCI device ID.
	DeviceID uint32
	// DeviceType indicates the type of GPU (discrete, integrated, etc.).
	DeviceType DeviceType
	// Driver is the driver version string.
	Driver string
	// DriverInfo is additional driver information.
	DriverInfo string
	// Backend is the graphics API backend in use.
	Backend Backend
}

AdapterInfo contains information about a GPU adapter.

type AddressMode

type AddressMode uint32

AddressMode describes texture coordinate addressing.

Determines how texture coordinates outside [0.0, 1.0] are handled.

const (
	// AddressModeUndefined is an undefined address mode (invalid).
	AddressModeUndefined AddressMode = 0x00000000
	// AddressModeClampToEdge clamps coordinates to the edge texel.
	AddressModeClampToEdge AddressMode = 0x00000001
	// AddressModeRepeat repeats the texture (wrapping).
	AddressModeRepeat AddressMode = 0x00000002
	// AddressModeMirrorRepeat repeats with mirroring.
	AddressModeMirrorRepeat AddressMode = 0x00000003
)

func (AddressMode) String

func (m AddressMode) String() string

String returns the address mode name.

type Backend

type Backend uint8

Backend identifies the graphics API backend.

const (
	// BackendEmpty represents no backend (invalid state).
	BackendEmpty Backend = iota
	// BackendVulkan uses the Vulkan API (cross-platform).
	BackendVulkan
	// BackendMetal uses Apple's Metal API (macOS, iOS).
	BackendMetal
	// BackendDX12 uses Microsoft DirectX 12 (Windows).
	BackendDX12
	// BackendGL uses OpenGL/OpenGL ES (legacy fallback).
	BackendGL
	// BackendBrowserWebGPU uses the browser's native WebGPU (WASM).
	BackendBrowserWebGPU
)

func (Backend) String

func (b Backend) String() string

String returns the backend name.

type Backends

type Backends uint8

Backends is a set of backend flags.

const (
	// BackendsNone includes no backends.
	BackendsNone Backends = 0
	// BackendsVulkan includes Vulkan.
	BackendsVulkan Backends = 1 << BackendVulkan
	// BackendsMetal includes Metal.
	BackendsMetal Backends = 1 << BackendMetal
	// BackendsDX12 includes DirectX 12.
	BackendsDX12 Backends = 1 << BackendDX12
	// BackendsGL includes OpenGL/OpenGL ES.
	BackendsGL Backends = 1 << BackendGL
	// BackendsBrowserWebGPU includes browser WebGPU.
	BackendsBrowserWebGPU Backends = 1 << BackendBrowserWebGPU

	// BackendsPrimary includes all primary backends (Vulkan, Metal, DX12, BrowserWebGPU).
	BackendsPrimary = BackendsVulkan | BackendsMetal | BackendsDX12 | BackendsBrowserWebGPU
	// BackendsSecondary includes fallback backends (GL only).
	BackendsSecondary = BackendsGL
	// BackendsAll includes all backends.
	BackendsAll = BackendsPrimary | BackendsSecondary
)

func (Backends) Contains

func (b Backends) Contains(backend Backend) bool

Contains checks if the backend set contains a specific backend.

type BindGroupDescriptor

type BindGroupDescriptor struct {
	// Label is an optional debug label.
	Label string
	// Layout is a handle to the bind group layout (implementation-specific).
	Layout uintptr
	// Entries are the bind group entries.
	Entries []BindGroupEntry
}

BindGroupDescriptor describes a bind group.

type BindGroupEntry

type BindGroupEntry struct {
	// Binding is the binding number.
	Binding uint32
	// Resource is the bound resource.
	Resource BindingResource
}

BindGroupEntry describes a single binding in a bind group.

type BindGroupLayoutDescriptor

type BindGroupLayoutDescriptor struct {
	// Label is an optional debug label.
	Label string
	// Entries are the layout entries.
	Entries []BindGroupLayoutEntry
}

BindGroupLayoutDescriptor describes a bind group layout.

type BindGroupLayoutEntry

type BindGroupLayoutEntry struct {
	// Binding is the binding number (must match @binding in shader).
	Binding uint32
	// Visibility specifies which shader stages can access this binding.
	Visibility ShaderStages
	// Buffer describes a buffer binding (nil if not a buffer).
	Buffer *BufferBindingLayout
	// Sampler describes a sampler binding (nil if not a sampler).
	Sampler *SamplerBindingLayout
	// Texture describes a texture binding (nil if not a texture).
	Texture *TextureBindingLayout
	// StorageTexture describes a storage texture binding (nil if not storage).
	StorageTexture *StorageTextureBindingLayout
	// AccelerationStructure describes an acceleration structure binding (nil if not AS).
	// Requires FeatureRayQuery.
	AccelerationStructure *AccelerationStructureBindingLayout
}

BindGroupLayoutEntry describes a single binding in a bind group layout.

Exactly one of Buffer, Sampler, Texture, or StorageTexture must be set.

type BindingResource

type BindingResource interface {
	// contains filtered or unexported methods
}

BindingResource is a resource that can be bound in a bind group.

Implementations include:

  • BufferBinding for buffer resources
  • SamplerBinding for sampler resources
  • TextureViewBinding for texture view resources

type BlasAABBGeometrySizeDescriptor added in v0.6.0

type BlasAABBGeometrySizeDescriptor struct {
	// PrimitiveCount is the number of AABB primitives.
	PrimitiveCount uint32
	// Flags are per-geometry flags.
	Flags AccelerationStructureGeometryFlags
}

BlasAABBGeometrySizeDescriptor describes the size parameters for a BLAS AABB geometry.

type BlasGeometrySizeDescriptors added in v0.6.0

type BlasGeometrySizeDescriptors struct {
	// Triangles contains triangle geometry descriptors (mutually exclusive with AABBs).
	Triangles []BlasTriangleGeometrySizeDescriptor
	// AABBs contains AABB geometry descriptors (mutually exclusive with Triangles).
	AABBs []BlasAABBGeometrySizeDescriptor
}

BlasGeometrySizeDescriptors is a discriminated union of BLAS geometry size descriptors. Exactly one of Triangles or AABBs must be non-nil.

type BlasTriangleGeometrySizeDescriptor added in v0.6.0

type BlasTriangleGeometrySizeDescriptor struct {
	// VertexFormat is the vertex position format (must be Float32x3 unless
	// FeatureExtendedASVertexFormats is enabled).
	VertexFormat VertexFormat
	// VertexCount is the number of vertices.
	VertexCount uint32
	// IndexFormat is the index format (nil for non-indexed geometry).
	IndexFormat *IndexFormat
	// IndexCount is the number of indices (nil for non-indexed geometry).
	IndexCount *uint32
	// Flags are per-geometry flags.
	Flags AccelerationStructureGeometryFlags
}

BlasTriangleGeometrySizeDescriptor describes the size parameters for a BLAS triangle geometry.

type BlendComponent

type BlendComponent struct {
	// SrcFactor is the source blend factor.
	SrcFactor BlendFactor
	// DstFactor is the destination blend factor.
	DstFactor BlendFactor
	// Operation is the blend operation.
	Operation BlendOperation
}

BlendComponent describes blending for a single color component (RGB or alpha).

func (BlendComponent) UsesConstant added in v0.4.0

func (bc BlendComponent) UsesConstant() bool

UsesConstant returns true if this blend component uses the blend constant color (BlendFactorConstant or BlendFactorOneMinusConstant). Matches Rust wgpu-types BlendComponent::uses_constant().

type BlendFactor

type BlendFactor uint32

BlendFactor describes a blend factor for color blending.

const (
	// BlendFactorUndefined is an undefined blend factor (invalid).
	BlendFactorUndefined BlendFactor = 0x00000000
	// BlendFactorZero uses 0.
	BlendFactorZero BlendFactor = 0x00000001
	// BlendFactorOne uses 1.
	BlendFactorOne BlendFactor = 0x00000002
	// BlendFactorSrc uses the source color.
	BlendFactorSrc BlendFactor = 0x00000003
	// BlendFactorOneMinusSrc uses (1 - source color).
	BlendFactorOneMinusSrc BlendFactor = 0x00000004
	// BlendFactorSrcAlpha uses the source alpha.
	BlendFactorSrcAlpha BlendFactor = 0x00000005
	// BlendFactorOneMinusSrcAlpha uses (1 - source alpha).
	BlendFactorOneMinusSrcAlpha BlendFactor = 0x00000006
	// BlendFactorDst uses the destination color.
	BlendFactorDst BlendFactor = 0x00000007
	// BlendFactorOneMinusDst uses (1 - destination color).
	BlendFactorOneMinusDst BlendFactor = 0x00000008
	// BlendFactorDstAlpha uses the destination alpha.
	BlendFactorDstAlpha BlendFactor = 0x00000009
	// BlendFactorOneMinusDstAlpha uses (1 - destination alpha).
	BlendFactorOneMinusDstAlpha BlendFactor = 0x0000000A
	// BlendFactorSrcAlphaSaturated uses min(source alpha, 1 - destination alpha).
	BlendFactorSrcAlphaSaturated BlendFactor = 0x0000000B
	// BlendFactorConstant uses the constant blend color.
	BlendFactorConstant BlendFactor = 0x0000000C
	// BlendFactorOneMinusConstant uses (1 - constant blend color).
	BlendFactorOneMinusConstant BlendFactor = 0x0000000D
)

func (BlendFactor) String

func (f BlendFactor) String() string

String returns the blend factor name.

type BlendOperation

type BlendOperation uint32

BlendOperation describes a blend operation.

const (
	// BlendOperationUndefined is an undefined blend operation (invalid).
	BlendOperationUndefined BlendOperation = 0x00000000
	// BlendOperationAdd computes src + dst.
	BlendOperationAdd BlendOperation = 0x00000001
	// BlendOperationSubtract computes src - dst.
	BlendOperationSubtract BlendOperation = 0x00000002
	// BlendOperationReverseSubtract computes dst - src.
	BlendOperationReverseSubtract BlendOperation = 0x00000003
	// BlendOperationMin computes min(src, dst).
	BlendOperationMin BlendOperation = 0x00000004
	// BlendOperationMax computes max(src, dst).
	BlendOperationMax BlendOperation = 0x00000005
)

func (BlendOperation) String

func (op BlendOperation) String() string

String returns the blend operation name.

type BlendState

type BlendState struct {
	// Color describes RGB channel blending.
	Color BlendComponent
	// Alpha describes alpha channel blending.
	Alpha BlendComponent
}

BlendState describes color blending for a render target.

func BlendStateAlpha

func BlendStateAlpha() BlendState

BlendStateAlpha returns a standard alpha blending state.

This is the most common blend state for transparent rendering.

func BlendStatePremultiplied

func BlendStatePremultiplied() BlendState

BlendStatePremultiplied returns a blend state for premultiplied alpha.

func BlendStateReplace

func BlendStateReplace() BlendState

BlendStateReplace returns a blend state that replaces the destination.

type BufferBinding

type BufferBinding struct {
	// Buffer is a handle to the buffer (implementation-specific).
	Buffer uintptr
	// Offset is the byte offset into the buffer.
	Offset uint64
	// Size is the byte size of the binding (0 for entire buffer from offset).
	Size uint64
}

BufferBinding binds a buffer range to a binding slot.

type BufferBindingLayout

type BufferBindingLayout struct {
	// Type is the buffer binding type.
	Type BufferBindingType
	// HasDynamicOffset indicates if the buffer has a dynamic offset.
	HasDynamicOffset bool
	// MinBindingSize is the minimum buffer size required (0 for no constraint).
	MinBindingSize uint64
}

BufferBindingLayout describes a buffer binding in a bind group layout.

type BufferBindingType

type BufferBindingType uint32

BufferBindingType describes how a buffer is bound in a bind group.

const (
	// BufferBindingTypeUndefined is an undefined binding type (invalid).
	BufferBindingTypeUndefined BufferBindingType = 0x00000000
	// BufferBindingTypeUniform binds as a uniform buffer (read-only in shaders).
	BufferBindingTypeUniform BufferBindingType = 0x00000001
	// BufferBindingTypeStorage binds as a storage buffer (read-write in shaders).
	BufferBindingTypeStorage BufferBindingType = 0x00000002
	// BufferBindingTypeReadOnlyStorage binds as a read-only storage buffer.
	BufferBindingTypeReadOnlyStorage BufferBindingType = 0x00000003
)

func (BufferBindingType) String

func (t BufferBindingType) String() string

String returns the binding type name.

type BufferDescriptor

type BufferDescriptor struct {
	// Label is an optional debug label.
	Label string
	// Size is the buffer size in bytes.
	Size uint64
	// Usage describes how the buffer will be used.
	Usage BufferUsage
	// MappedAtCreation indicates if the buffer should be mapped at creation.
	// If true, the buffer must have MapRead or MapWrite usage.
	MappedAtCreation bool
}

BufferDescriptor describes a buffer.

type BufferMapState

type BufferMapState uint32

BufferMapState describes the map state of a buffer.

const (
	// BufferMapStateUnmapped means the buffer is not mapped.
	BufferMapStateUnmapped BufferMapState = iota
	// BufferMapStatePending means a map operation is pending.
	BufferMapStatePending
	// BufferMapStateMapped means the buffer is currently mapped.
	BufferMapStateMapped
)

func (BufferMapState) String

func (s BufferMapState) String() string

String returns the map state name.

type BufferUsage

type BufferUsage uint64

BufferUsage describes how a buffer can be used.

This is a bit flag type. Combine multiple usages with bitwise OR.

const (
	// BufferUsageNone indicates no usage (invalid for most operations).
	BufferUsageNone BufferUsage = 0x0000000000000000
	// BufferUsageMapRead allows mapping the buffer for reading.
	BufferUsageMapRead BufferUsage = 0x0000000000000001
	// BufferUsageMapWrite allows mapping the buffer for writing.
	BufferUsageMapWrite BufferUsage = 0x0000000000000002
	// BufferUsageCopySrc allows the buffer to be a copy source.
	BufferUsageCopySrc BufferUsage = 0x0000000000000004
	// BufferUsageCopyDst allows the buffer to be a copy destination.
	BufferUsageCopyDst BufferUsage = 0x0000000000000008
	// BufferUsageIndex allows use as an index buffer.
	BufferUsageIndex BufferUsage = 0x0000000000000010
	// BufferUsageVertex allows use as a vertex buffer.
	BufferUsageVertex BufferUsage = 0x0000000000000020
	// BufferUsageUniform allows use as a uniform buffer.
	BufferUsageUniform BufferUsage = 0x0000000000000040
	// BufferUsageStorage allows use as a storage buffer.
	BufferUsageStorage BufferUsage = 0x0000000000000080
	// BufferUsageIndirect allows use for indirect draw/dispatch commands.
	BufferUsageIndirect BufferUsage = 0x0000000000000100
	// BufferUsageQueryResolve allows use for query result resolution.
	BufferUsageQueryResolve BufferUsage = 0x0000000000000200

	// BufferUsageAccelerationStructureScratch allows use as scratch space during AS build.
	BufferUsageAccelerationStructureScratch BufferUsage = 0x0000000000000800
	// BufferUsageBlasInput allows use as BLAS build input (vertex/index/transform/AABB data).
	BufferUsageBlasInput BufferUsage = 0x0000000000001000
	// BufferUsageTlasInput allows use as TLAS build input (instance data).
	BufferUsageTlasInput BufferUsage = 0x0000000000002000
	// BufferUsageAccelerationStructureQuery allows use for AS compaction size readback.
	BufferUsageAccelerationStructureQuery BufferUsage = 0x0000000000004000
)

func (BufferUsage) Contains

func (u BufferUsage) Contains(flag BufferUsage) bool

Contains returns true if the usage includes the given flag.

func (BufferUsage) ContainsUnknownBits

func (u BufferUsage) ContainsUnknownBits() bool

ContainsUnknownBits returns true if the usage contains any unknown flags.

type Color

type Color struct {
	// R is the red component.
	R float64
	// G is the green component.
	G float64
	// B is the blue component.
	B float64
	// A is the alpha (opacity) component.
	A float64
}

Color represents an RGBA color with float64 components.

Each component is typically in the range [0.0, 1.0] for standard colors, though HDR colors may use values outside this range.

func NewColor

func NewColor(r, g, b, a float64) Color

NewColor creates a new Color with the given RGBA values.

func NewColorRGB

func NewColorRGB(r, g, b float64) Color

NewColorRGB creates a new opaque Color with the given RGB values and alpha=1.0.

func (Color) Premultiplied

func (c Color) Premultiplied() Color

Premultiplied returns the color with RGB components multiplied by alpha.

func (Color) RGBA

func (c Color) RGBA() (r, g, b, a float64)

RGBA returns the color components as individual values.

func (Color) WithAlpha

func (c Color) WithAlpha(a float64) Color

WithAlpha returns a copy of the color with a new alpha value.

type ColorTargetState

type ColorTargetState struct {
	// Format is the texture format of the target.
	Format TextureFormat
	// Blend describes color blending (nil for no blending).
	Blend *BlendState
	// WriteMask specifies which color channels to write.
	WriteMask ColorWriteMask
}

ColorTargetState describes a color target in a render pipeline.

type ColorWriteMask

type ColorWriteMask uint32

ColorWriteMask describes which color channels to write.

This is a bit flag type.

const (
	// ColorWriteMaskNone writes no channels.
	ColorWriteMaskNone ColorWriteMask = 0x00000000
	// ColorWriteMaskRed writes the red channel.
	ColorWriteMaskRed ColorWriteMask = 0x00000001
	// ColorWriteMaskGreen writes the green channel.
	ColorWriteMaskGreen ColorWriteMask = 0x00000002
	// ColorWriteMaskBlue writes the blue channel.
	ColorWriteMaskBlue ColorWriteMask = 0x00000004
	// ColorWriteMaskAlpha writes the alpha channel.
	ColorWriteMaskAlpha ColorWriteMask = 0x00000008
	// ColorWriteMaskAll writes all channels.
	ColorWriteMaskAll ColorWriteMask = 0x0000000F
)

type CompareFunction

type CompareFunction uint32

CompareFunction describes a comparison function.

Used for depth testing and sampler comparison.

const (
	// CompareFunctionUndefined is undefined (no comparison).
	CompareFunctionUndefined CompareFunction = 0x00000000
	// CompareFunctionNever always fails.
	CompareFunctionNever CompareFunction = 0x00000001
	// CompareFunctionLess passes if source < destination.
	CompareFunctionLess CompareFunction = 0x00000002
	// CompareFunctionEqual passes if source == destination.
	CompareFunctionEqual CompareFunction = 0x00000003
	// CompareFunctionLessEqual passes if source <= destination.
	CompareFunctionLessEqual CompareFunction = 0x00000004
	// CompareFunctionGreater passes if source > destination.
	CompareFunctionGreater CompareFunction = 0x00000005
	// CompareFunctionNotEqual passes if source != destination.
	CompareFunctionNotEqual CompareFunction = 0x00000006
	// CompareFunctionGreaterEqual passes if source >= destination.
	CompareFunctionGreaterEqual CompareFunction = 0x00000007
	// CompareFunctionAlways always passes.
	CompareFunctionAlways CompareFunction = 0x00000008
)

func (CompareFunction) String

func (f CompareFunction) String() string

String returns the compare function name.

type CompositeAlphaMode

type CompositeAlphaMode uint32

CompositeAlphaMode specifies how alpha channel is handled during compositing.

const (
	// CompositeAlphaModeAuto chooses Opaque or Inherit automatically.
	CompositeAlphaModeAuto CompositeAlphaMode = 0x00000000

	// CompositeAlphaModeOpaque ignores alpha, treats texture as fully opaque.
	CompositeAlphaModeOpaque CompositeAlphaMode = 0x00000001

	// CompositeAlphaModePremultiplied expects colors to be pre-multiplied by alpha.
	CompositeAlphaModePremultiplied CompositeAlphaMode = 0x00000002

	// CompositeAlphaModeUnpremultiplied has compositor multiply colors by alpha.
	CompositeAlphaModeUnpremultiplied CompositeAlphaMode = 0x00000003

	// CompositeAlphaModeInherit uses platform-specific default.
	CompositeAlphaModeInherit CompositeAlphaMode = 0x00000004
)

func (CompositeAlphaMode) String

func (m CompositeAlphaMode) String() string

String returns the string representation of CompositeAlphaMode.

type CreateBlasDescriptor added in v0.6.0

type CreateBlasDescriptor struct {
	// Label is an optional debug label.
	Label string
	// Flags are acceleration structure creation flags.
	Flags AccelerationStructureFlags
	// UpdateMode determines how the BLAS is updated after initial build.
	UpdateMode AccelerationStructureUpdateMode
}

CreateBlasDescriptor describes a bottom-level acceleration structure to create.

type CreateTlasDescriptor added in v0.6.0

type CreateTlasDescriptor struct {
	// Label is an optional debug label.
	Label string
	// MaxInstances is the maximum number of instances this TLAS can hold.
	MaxInstances uint32
	// Flags are acceleration structure creation flags.
	Flags AccelerationStructureFlags
	// UpdateMode determines how the TLAS is updated after initial build.
	UpdateMode AccelerationStructureUpdateMode
}

CreateTlasDescriptor describes a top-level acceleration structure to create.

type CullMode

type CullMode uint32

CullMode describes which faces to cull.

The zero value is CullModeNone, matching the WebGPU spec default ( https://gpuweb.github.io/gpuweb/#enumdef-gpucullmode ).

const (
	// CullModeNone culls no faces. This is the zero value and WebGPU spec default.
	CullModeNone CullMode = 0
	// CullModeFront culls front faces.
	CullModeFront CullMode = 1
	// CullModeBack culls back faces.
	CullModeBack CullMode = 2
)

func (CullMode) String

func (m CullMode) String() string

String returns the cull mode name.

type DepthStencilState

type DepthStencilState struct {
	// Format is the depth/stencil texture format.
	Format TextureFormat
	// DepthWriteEnabled enables depth writing.
	DepthWriteEnabled bool
	// DepthCompare is the depth comparison function.
	DepthCompare CompareFunction
	// StencilFront describes front face stencil state.
	StencilFront StencilFaceState
	// StencilBack describes back face stencil state.
	StencilBack StencilFaceState
	// StencilReadMask is the mask for stencil reads.
	StencilReadMask uint32
	// StencilWriteMask is the mask for stencil writes.
	StencilWriteMask uint32
	// DepthBias is the constant depth bias.
	DepthBias int32
	// DepthBiasSlopeScale is the slope-based depth bias.
	DepthBiasSlopeScale float32
	// DepthBiasClamp is the maximum depth bias.
	DepthBiasClamp float32
}

DepthStencilState describes depth and stencil state.

func DefaultDepthStencilState

func DefaultDepthStencilState(format TextureFormat) DepthStencilState

DefaultDepthStencilState returns a depth-stencil state with depth testing enabled.

type DeviceDescriptor

type DeviceDescriptor struct {
	// Label is an optional debug label.
	Label string
	// RequiredFeatures lists features the device must support.
	RequiredFeatures []Feature
	// RequiredLimits specifies limits the device must meet.
	RequiredLimits Limits
	// MemoryHints provides memory allocation hints.
	MemoryHints MemoryHints
}

DeviceDescriptor describes how to create a GPU device.

func DefaultDeviceDescriptor

func DefaultDeviceDescriptor() DeviceDescriptor

DefaultDeviceDescriptor returns a device descriptor with default settings.

type DeviceType

type DeviceType uint8

DeviceType identifies the type of GPU device.

const (
	// DeviceTypeOther is an unknown or other device type.
	DeviceTypeOther DeviceType = iota
	// DeviceTypeIntegratedGPU is integrated into the CPU (shared memory).
	DeviceTypeIntegratedGPU
	// DeviceTypeDiscreteGPU is a separate GPU with dedicated memory.
	DeviceTypeDiscreteGPU
	// DeviceTypeVirtualGPU is a virtual GPU (e.g., in a VM).
	DeviceTypeVirtualGPU
	// DeviceTypeCPU is software rendering on the CPU.
	DeviceTypeCPU
)

func (DeviceType) String

func (d DeviceType) String() string

String returns the device type name.

type DownlevelCapabilities added in v0.7.0

type DownlevelCapabilities struct {
	// Flags is the combined boolean flags.
	Flags DownlevelFlags
	// Limits is the additional limits for downlevel adapters.
	Limits DownlevelLimits
	// ShaderModel indicates which collections of shader features are supported.
	ShaderModel ShaderModel
}

DownlevelCapabilities lists various ways the underlying platform does not conform to the WebGPU standard. Matches Rust wgpu-types DownlevelCapabilities (limits.rs:1056-1063).

func DefaultDownlevelCapabilities added in v0.7.0

func DefaultDownlevelCapabilities() DownlevelCapabilities

DefaultDownlevelCapabilities returns the default DownlevelCapabilities, representing a fully WebGPU-compliant adapter. Matches Rust Default for DownlevelCapabilities (limits.rs:1065-1072).

func (DownlevelCapabilities) IsWebGPUCompliant added in v0.7.0

func (dc DownlevelCapabilities) IsWebGPUCompliant() bool

IsWebGPUCompliant returns true if the underlying platform offers complete support of the baseline WebGPU standard.

If this returns false, some parts of the API will result in validation errors where they would not normally. These parts can be determined by the values in this structure. Matches Rust DownlevelCapabilities::is_webgpu_compliant() (limits.rs:1075-1085).

type DownlevelFlags added in v0.7.0

type DownlevelFlags uint32

DownlevelFlags represents binary flags listing features that may or may not be present on downlevel adapters.

The W3C WebGPU spec assumes all adapters meet a baseline (compute, indirect draw, etc.) and simply excludes non-conformant hardware from requestAdapter(). As a native Go library, we support backends below that baseline (GLES 3.0, CPU software rasterizer) and degrade gracefully instead of refusing to run. DownlevelFlags tracks exactly what each backend supports, enabling consumers to make informed decisions (e.g., GPU compute vs CPU fallback).

This is a Rust wgpu extension — the term "downlevel" does not appear in the W3C WebGPU specification. Of 27 flags, 24 track capabilities required by the spec for core (conformant) adapters, 1 (AnisotropicFiltering) is not required by the spec, and 2 (MSL21, SurfaceViewFormats) are backend-specific.

You can check whether a set of flags is compliant through the DownlevelCapabilities.IsWebGPUCompliant method.

Bit positions match Rust wgpu-types (limits.rs:1102-1246).

const (
	// DownlevelFlagsComputeShaders indicates the device supports compiling and using compute shaders.
	// WebGL2 and GLES 3.0 devices do not support compute.
	DownlevelFlagsComputeShaders DownlevelFlags = 1 << 0

	// DownlevelFlagsFragmentWritableStorage indicates support for binding storage buffers
	// and textures to fragment shaders.
	DownlevelFlagsFragmentWritableStorage DownlevelFlags = 1 << 1

	// DownlevelFlagsIndirectExecution indicates support for indirect drawing and dispatching.
	// DownlevelFlagsComputeShaders must be present for this flag.
	// WebGL2, GLES 3.0, and Metal on Apple1/Apple2 GPUs do not support indirect.
	DownlevelFlagsIndirectExecution DownlevelFlags = 1 << 2

	// DownlevelFlagsBaseVertex indicates support for non-zero base_vertex parameter
	// to direct indexed draw calls.
	// Indirect calls, if supported, always support non-zero base_vertex.
	DownlevelFlagsBaseVertex DownlevelFlags = 1 << 3

	// DownlevelFlagsReadOnlyDepthStencil indicates support for reading from a depth/stencil
	// texture while using it as a read-only depth/stencil attachment.
	// The WebGL2 and GLES backends do not support RODS.
	DownlevelFlagsReadOnlyDepthStencil DownlevelFlags = 1 << 4

	// DownlevelFlagsNonPowerOfTwoMipmappedTextures indicates support for textures with mipmaps
	// which have a non power of two size.
	DownlevelFlagsNonPowerOfTwoMipmappedTextures DownlevelFlags = 1 << 5

	// DownlevelFlagsCubeArrayTextures indicates support for textures that are cube arrays.
	DownlevelFlagsCubeArrayTextures DownlevelFlags = 1 << 6

	// DownlevelFlagsComparisonSamplers indicates support for comparison samplers.
	DownlevelFlagsComparisonSamplers DownlevelFlags = 1 << 7

	// DownlevelFlagsIndependentBlend indicates support for different blend operations
	// per color attachment.
	DownlevelFlagsIndependentBlend DownlevelFlags = 1 << 8

	// DownlevelFlagsVertexStorage indicates support for storage buffers in vertex shaders.
	DownlevelFlagsVertexStorage DownlevelFlags = 1 << 9

	// DownlevelFlagsAnisotropicFiltering indicates support for samplers with anisotropic filtering.
	// Note this isn't actually required by WebGPU; the implementation is allowed to completely
	// ignore aniso clamp. This flag is here for native backends so they can communicate
	// to the user if aniso is enabled.
	// All backends and all devices support anisotropic filtering.
	DownlevelFlagsAnisotropicFiltering DownlevelFlags = 1 << 10

	// DownlevelFlagsFragmentStorage indicates support for storage buffers in fragment shaders.
	DownlevelFlagsFragmentStorage DownlevelFlags = 1 << 11

	// DownlevelFlagsMultisampledShading indicates support for sample-rate shading.
	DownlevelFlagsMultisampledShading DownlevelFlags = 1 << 12

	// DownlevelFlagsDepthTextureAndBufferCopies indicates support for copies between
	// depth textures and buffers.
	// GLES/WebGL don't support this.
	DownlevelFlagsDepthTextureAndBufferCopies DownlevelFlags = 1 << 13

	// DownlevelFlagsWebGPUTextureFormatSupport indicates support for all the texture usages
	// described in WebGPU. If this isn't supported, call GetTextureFormatFeatures to determine
	// how you can use textures of a given format.
	DownlevelFlagsWebGPUTextureFormatSupport DownlevelFlags = 1 << 14

	// DownlevelFlagsBufferBindingsNot16ByteAligned indicates support for buffer bindings
	// with sizes that aren't a multiple of 16.
	// WebGL doesn't support this.
	DownlevelFlagsBufferBindingsNot16ByteAligned DownlevelFlags = 1 << 15

	// DownlevelFlagsUnrestrictedIndexBuffer indicates support for buffers to combine INDEX
	// usage with usages other than COPY_DST and COPY_SRC.
	// WebGL doesn't support this.
	DownlevelFlagsUnrestrictedIndexBuffer DownlevelFlags = 1 << 16

	// DownlevelFlagsFullDrawIndexUint32 indicates support for full 32-bit range indices
	// (2^32-1 as opposed to 2^24-1 without this flag).
	// Corresponds to Vulkan's VkPhysicalDeviceFeatures.fullDrawIndexUint32.
	DownlevelFlagsFullDrawIndexUint32 DownlevelFlags = 1 << 17

	// DownlevelFlagsDepthBiasClamp indicates support for depth bias clamping.
	// Corresponds to Vulkan's VkPhysicalDeviceFeatures.depthBiasClamp.
	DownlevelFlagsDepthBiasClamp DownlevelFlags = 1 << 18

	// DownlevelFlagsViewFormats indicates support for specifying which view format values
	// are allowed when create_view() is called on a texture.
	// The WebGL and GLES backends don't support this.
	DownlevelFlagsViewFormats DownlevelFlags = 1 << 19

	// DownlevelFlagsUnrestrictedExternalTextureCopies indicates support for unrestricted
	// external texture copy operations.
	// WebGL doesn't support this. WebGPU does.
	DownlevelFlagsUnrestrictedExternalTextureCopies DownlevelFlags = 1 << 20

	// DownlevelFlagsSurfaceViewFormats indicates support for specifying which view formats
	// are allowed when calling create_view on the texture returned by Surface.GetCurrentTexture.
	// The GLES/WebGL and Vulkan on Android don't support this.
	DownlevelFlagsSurfaceViewFormats DownlevelFlags = 1 << 21

	// DownlevelFlagsNonblockingQueryResolve indicates that calls to
	// CommandEncoder.ResolveQuerySet will be performed on the queue timeline.
	// If false, resolve will be performed on the device (CPU) timeline and will block
	// until the query has data.
	DownlevelFlagsNonblockingQueryResolve DownlevelFlags = 1 << 22

	// DownlevelFlagsShaderF16InF32 allows shaders to use quantizeToF16, pack2x16float,
	// and unpack2x16float, which operate on f16-precision values stored in f32s.
	// Not supported by Vulkan on Mesa when FeatureShaderF16 is absent.
	DownlevelFlagsShaderF16InF32 DownlevelFlags = 1 << 23

	// DownlevelFlagsMSL21 indicates support for features introduced in MSL 2.1.
	DownlevelFlagsMSL21 DownlevelFlags = 1 << 24

	// DownlevelFlagsTextureCompression indicates the adapter supports the WebGPU texture
	// compression requirement: BC || (ETC2 && ASTC).
	// See https://www.w3.org/TR/webgpu/#adapter-capability-guarantees.
	DownlevelFlagsTextureCompression DownlevelFlags = 1 << 25

	// DownlevelFlagsLinearInterpolation indicates support for @interpolate(linear)
	// (a.k.a. noperspective) on shader inter-stage variables.
	// GLSL ES has no noperspective qualifier, so the GLES backend only supports this
	// on desktop OpenGL, not on GLES/WebGL2.
	DownlevelFlagsLinearInterpolation DownlevelFlags = 1 << 26
)

func DownlevelFlagsAll added in v0.7.0

func DownlevelFlagsAll() DownlevelFlags

DownlevelFlagsAll returns a DownlevelFlags value with all 27 bits set.

func DownlevelFlagsCompliant added in v0.7.0

func DownlevelFlagsCompliant() DownlevelFlags

DownlevelFlagsCompliant returns all flags that indicate WebGPU compliance. This is all flags except AnisotropicFiltering, which is not required by WebGPU. Matches Rust wgpu-types DownlevelFlags::compliant() (limits.rs:1249-1257).

func (DownlevelFlags) Contains added in v0.7.0

func (f DownlevelFlags) Contains(flag DownlevelFlags) bool

Contains reports whether f contains all bits in flag.

func (DownlevelFlags) String added in v0.7.0

func (f DownlevelFlags) String() string

String returns a human-readable representation of the flags.

type DownlevelLimits

type DownlevelLimits struct{}

DownlevelLimits represents additional limits on a downlevel adapter. Currently empty, reserved for future use. Matches Rust wgpu-types DownlevelLimits (limits.rs:1044).

type DrawArgs added in v0.8.0

type DrawArgs struct {
	// VertexCount is the number of vertices to draw.
	VertexCount uint32
	// InstanceCount is the number of instances to draw.
	InstanceCount uint32
	// FirstVertex is the index of the first vertex to draw.
	FirstVertex uint32
	// FirstInstance is the instance ID of the first instance to draw.
	// Must be 0 unless FeatureIndirectFirstInstance is enabled.
	FirstInstance uint32
}

DrawArgs describes parameters for a non-indexed draw call.

Field layout matches VkDrawIndirectCommand and D3D12_DRAW_ARGUMENTS exactly, enabling zero-copy use as indirect draw argument buffers. Using a struct instead of 4 positional uint32 prevents silent argument swap bugs (Go has no named arguments).

type DrawIndexedArgs added in v0.8.0

type DrawIndexedArgs struct {
	// IndexCount is the number of indices to draw.
	IndexCount uint32
	// InstanceCount is the number of instances to draw.
	InstanceCount uint32
	// FirstIndex is the offset into the index buffer.
	FirstIndex uint32
	// BaseVertex is the value added to the vertex index before
	// indexing into the vertex buffer. Signed to allow negative offsets.
	BaseVertex int32
	// FirstInstance is the instance ID of the first instance to draw.
	// Must be 0 unless FeatureIndirectFirstInstance is enabled.
	FirstInstance uint32
}

DrawIndexedArgs describes parameters for an indexed draw call.

Field layout matches VkDrawIndexedIndirectCommand and D3D12_DRAW_INDEXED_ARGUMENTS exactly, enabling zero-copy use as indirect draw argument buffers.

type Dx12ShaderCompiler

type Dx12ShaderCompiler uint8

Dx12ShaderCompiler specifies the shader compiler for DX12 backend.

const (
	// Dx12ShaderCompilerFxc uses the legacy FXC compiler.
	Dx12ShaderCompilerFxc Dx12ShaderCompiler = iota
	// Dx12ShaderCompilerDxc uses the modern DXC compiler.
	Dx12ShaderCompilerDxc
)

func (Dx12ShaderCompiler) String

func (c Dx12ShaderCompiler) String() string

String returns the DX12 shader compiler name.

type Extent3D

type Extent3D struct {
	// Width is the size in the X dimension (must be > 0).
	Width uint32
	// Height is the size in the Y dimension (must be > 0).
	Height uint32
	// DepthOrArrayLayers is the size in Z or array layer count (must be > 0).
	DepthOrArrayLayers uint32
}

Extent3D describes a 3D size.

It is used for texture dimensions and copy operations. For 2D textures, DepthOrArrayLayers represents the array layer count. For 3D textures, it represents the depth.

func NewExtent2D

func NewExtent2D(width, height uint32) Extent3D

NewExtent2D creates an Extent3D for a 2D texture with 1 layer.

func NewExtent3D

func NewExtent3D(width, height, depth uint32) Extent3D

NewExtent3D creates an Extent3D for a 3D texture.

type Feature

type Feature uint64

Feature represents a WebGPU feature flag.

Features are optional capabilities that may not be available on all GPUs. Check Features.Contains() to determine if a feature is supported.

const (
	// FeatureDepthClipControl enables depth clip control (unclipped depth).
	FeatureDepthClipControl Feature = 1 << iota
	// FeatureDepth32FloatStencil8 enables the depth32float-stencil8 texture format.
	FeatureDepth32FloatStencil8
	// FeatureTextureCompressionBC enables BC texture compression formats.
	FeatureTextureCompressionBC
	// FeatureTextureCompressionETC2 enables ETC2 texture compression formats.
	FeatureTextureCompressionETC2
	// FeatureTextureCompressionASTC enables ASTC texture compression formats.
	FeatureTextureCompressionASTC
	// FeatureIndirectFirstInstance enables first instance parameter in indirect draws.
	FeatureIndirectFirstInstance
	// FeatureShaderF16 enables f16 (half-precision float) in shaders.
	FeatureShaderF16
	// FeatureRG11B10UfloatRenderable enables RG11B10Ufloat as a render target format.
	FeatureRG11B10UfloatRenderable
	// FeatureBGRA8UnormStorage enables BGRA8Unorm as a storage texture format.
	FeatureBGRA8UnormStorage
	// FeatureFloat32Filterable enables filtering of float32 textures.
	FeatureFloat32Filterable
	// FeatureTimestampQuery enables timestamp queries.
	FeatureTimestampQuery
	// FeaturePipelineStatisticsQuery enables pipeline statistics queries.
	FeaturePipelineStatisticsQuery
	// FeatureMultiDrawIndirect enables multi-draw indirect commands.
	FeatureMultiDrawIndirect
	// FeatureMultiDrawIndirectCount enables multi-draw indirect with count.
	FeatureMultiDrawIndirectCount
	// FeaturePushConstants enables push constants (non-standard extension).
	FeaturePushConstants
	// FeatureTextureAdapterSpecificFormatFeatures enables adapter-specific texture formats.
	FeatureTextureAdapterSpecificFormatFeatures
	// FeatureShaderFloat64 enables f64 (double-precision float) in shaders.
	FeatureShaderFloat64
	// FeatureVertexAttribute64bit enables 64-bit vertex attributes.
	FeatureVertexAttribute64bit
	// FeatureSubgroupOperations enables subgroup operations in shaders.
	FeatureSubgroupOperations
	// FeatureSubgroupBarrier enables subgroup barriers in shaders.
	FeatureSubgroupBarrier

	// FeatureRayQuery enables inline ray queries in compute and fragment shaders.
	// Experimental — not in W3C WebGPU spec (Milestone 4+).
	FeatureRayQuery
	// FeatureRayHitVertexReturn enables triangle vertex data retrieval on ray hit.
	FeatureRayHitVertexReturn
	// FeatureExtendedASVertexFormats enables Float32x2, Float16x2, Float16x4
	// as valid vertex formats for acceleration structure geometry.
	FeatureExtendedASVertexFormats
	// FeatureASBindingArray enables arrays of acceleration structures in shaders.
	FeatureASBindingArray
	// FeatureRayTracingPipelines enables dedicated ray tracing pipelines.
	FeatureRayTracingPipelines
)

func (Feature) String

func (f Feature) String() string

String returns the feature name.

type Features

type Features uint64

Features is a set of feature flags.

func (Features) Contains

func (f Features) Contains(feature Feature) bool

Contains checks if the feature set contains a specific feature.

func (Features) ContainsAll

func (f Features) ContainsAll(other Features) bool

ContainsAll checks if the feature set contains all specified features.

func (Features) Count

func (f Features) Count() int

Count returns the number of features in the set.

func (*Features) Insert

func (f *Features) Insert(feature Feature)

Insert adds a feature to the set.

func (Features) Intersect

func (f Features) Intersect(other Features) Features

Intersect returns features common to both sets.

func (Features) IsEmpty

func (f Features) IsEmpty() bool

IsEmpty returns true if no features are set.

func (*Features) Remove

func (f *Features) Remove(feature Feature)

Remove removes a feature from the set.

func (Features) Union

func (f Features) Union(other Features) Features

Union returns all features from both sets.

type FilterMode

type FilterMode uint32

FilterMode describes texture filtering.

Used for magnification and minification filters.

const (
	// FilterModeUndefined is an undefined filter mode (invalid).
	FilterModeUndefined FilterMode = 0x00000000
	// FilterModeNearest uses nearest-neighbor filtering (pixelated).
	FilterModeNearest FilterMode = 0x00000001
	// FilterModeLinear uses linear interpolation (smooth).
	FilterModeLinear FilterMode = 0x00000002
)

func (FilterMode) String

func (m FilterMode) String() string

String returns the filter mode name.

type FragmentState

type FragmentState struct {
	// Module is a handle to the shader module (implementation-specific).
	Module uintptr
	// EntryPoint is the fragment shader entry point function name.
	EntryPoint string
	// Constants are pipeline-overridable constants.
	Constants map[string]float64
	// Targets are the color target states.
	Targets []ColorTargetState
}

FragmentState describes the fragment stage of a render pipeline.

type FrontFace

type FrontFace uint32

FrontFace describes the front face winding order.

The zero value is FrontFaceCCW, matching the WebGPU spec default ( https://gpuweb.github.io/gpuweb/#enumdef-gpufrontface ).

const (
	// FrontFaceCCW treats counter-clockwise vertices as front-facing.
	// This is the zero value and WebGPU spec default.
	FrontFaceCCW FrontFace = 0
	// FrontFaceCW treats clockwise vertices as front-facing.
	FrontFaceCW FrontFace = 1
)

func (FrontFace) String

func (f FrontFace) String() string

String returns the front face name.

type GLBackend

type GLBackend uint8

GLBackend specifies the OpenGL backend flavor.

const (
	// GLBackendGL uses desktop OpenGL.
	GLBackendGL GLBackend = iota
	// GLBackendGLES uses OpenGL ES.
	GLBackendGLES
)

func (GLBackend) String

func (b GLBackend) String() string

String returns the GL backend name.

type ImageCopyTexture

type ImageCopyTexture struct {
	// Texture is a handle to the texture (implementation-specific).
	Texture uintptr
	// MipLevel is the mip level to copy.
	MipLevel uint32
	// Origin is the origin of the copy region in the texture.
	Origin Origin3D
	// Aspect is the aspect of the texture to copy.
	Aspect TextureAspect
}

ImageCopyTexture describes a texture copy source or destination.

type ImageSubresourceRange

type ImageSubresourceRange struct {
	// Aspect of the texture to access.
	// Color textures must use TextureAspectAll.
	Aspect TextureAspect

	// BaseMipLevel is the first mip level in the range.
	BaseMipLevel uint32

	// MipLevelCount is the number of mip levels.
	// If nil, includes all remaining mip levels (at least 1).
	MipLevelCount *uint32

	// BaseArrayLayer is the first array layer in the range.
	BaseArrayLayer uint32

	// ArrayLayerCount is the number of array layers.
	// If nil, includes all remaining layers (at least 1).
	ArrayLayerCount *uint32
}

ImageSubresourceRange describes a range of subresources within a texture.

Used for partial texture operations and views.

func (ImageSubresourceRange) IsFullResource

func (r ImageSubresourceRange) IsFullResource(mipLevelCount, arrayLayerCount uint32) bool

IsFullResource checks if this range covers the entire texture resource.

type IndexFormat

type IndexFormat uint32

IndexFormat describes the format of index buffer data.

const (
	// IndexFormatUndefined is an undefined index format (invalid).
	IndexFormatUndefined IndexFormat = 0x00000000
	// IndexFormatUint16 uses 16-bit unsigned integers (max 65535 indices).
	IndexFormatUint16 IndexFormat = 0x00000001
	// IndexFormatUint32 uses 32-bit unsigned integers.
	IndexFormatUint32 IndexFormat = 0x00000002
)

func (IndexFormat) Size

func (f IndexFormat) Size() uint32

Size returns the byte size of the index format.

func (IndexFormat) String

func (f IndexFormat) String() string

String returns the index format name.

type InstanceDescriptor

type InstanceDescriptor struct {
	// Backends specifies which backends to enable.
	Backends Backends
	// Flags controls instance behavior (debug, validation, etc.).
	Flags InstanceFlags
	// Dx12ShaderCompiler specifies the DX12 shader compiler.
	Dx12ShaderCompiler Dx12ShaderCompiler
	// GLBackend specifies the OpenGL backend flavor.
	GLBackend GLBackend
}

InstanceDescriptor describes how to create a GPU instance.

func DefaultInstanceDescriptor

func DefaultInstanceDescriptor() InstanceDescriptor

DefaultInstanceDescriptor returns an instance descriptor with default settings.

type InstanceFlags

type InstanceFlags uint8

InstanceFlags controls GPU instance behavior.

const (
	// InstanceFlagsNone uses default behavior.
	InstanceFlagsNone InstanceFlags = 0
	// InstanceFlagsDebug enables debug layers when available.
	InstanceFlagsDebug InstanceFlags = 1 << iota
	// InstanceFlagsValidation enables validation layers.
	InstanceFlagsValidation
	// InstanceFlagsGPUBasedValidation enables GPU-based validation (slower).
	InstanceFlagsGPUBasedValidation
	// InstanceFlagsDiscardHalLabels discards HAL debug labels.
	InstanceFlagsDiscardHalLabels
)

type Limits

type Limits struct {
	// MaxTextureDimension1D is the maximum 1D texture dimension.
	MaxTextureDimension1D uint32
	// MaxTextureDimension2D is the maximum 2D texture dimension.
	MaxTextureDimension2D uint32
	// MaxTextureDimension3D is the maximum 3D texture dimension.
	MaxTextureDimension3D uint32
	// MaxTextureArrayLayers is the maximum texture array layer count.
	MaxTextureArrayLayers uint32
	// MaxBindGroups is the maximum number of bind groups.
	MaxBindGroups uint32
	// MaxBindGroupsPlusVertexBuffers is the max bind groups + vertex buffers combined.
	MaxBindGroupsPlusVertexBuffers uint32
	// MaxBindingsPerBindGroup is the max bindings per bind group.
	MaxBindingsPerBindGroup uint32
	// MaxDynamicUniformBuffersPerPipelineLayout is the max dynamic uniform buffers per pipeline layout.
	MaxDynamicUniformBuffersPerPipelineLayout uint32
	// MaxDynamicStorageBuffersPerPipelineLayout is the max dynamic storage buffers per pipeline layout.
	MaxDynamicStorageBuffersPerPipelineLayout uint32
	// MaxSampledTexturesPerShaderStage is the max sampled textures per shader stage.
	MaxSampledTexturesPerShaderStage uint32
	// MaxSamplersPerShaderStage is the max samplers per shader stage.
	MaxSamplersPerShaderStage uint32
	// MaxStorageBuffersPerShaderStage is the max storage buffers per shader stage.
	MaxStorageBuffersPerShaderStage uint32
	// MaxStorageTexturesPerShaderStage is the max storage textures per shader stage.
	MaxStorageTexturesPerShaderStage uint32
	// MaxUniformBuffersPerShaderStage is the max uniform buffers per shader stage.
	MaxUniformBuffersPerShaderStage uint32
	// MaxUniformBufferBindingSize is the max uniform buffer binding size in bytes.
	MaxUniformBufferBindingSize uint64
	// MaxStorageBufferBindingSize is the max storage buffer binding size in bytes.
	MaxStorageBufferBindingSize uint64
	// MinUniformBufferOffsetAlignment is the minimum uniform buffer offset alignment.
	MinUniformBufferOffsetAlignment uint32
	// MinStorageBufferOffsetAlignment is the minimum storage buffer offset alignment.
	MinStorageBufferOffsetAlignment uint32
	// MaxVertexBuffers is the max vertex buffers in a pipeline.
	MaxVertexBuffers uint32
	// MaxBufferSize is the max buffer size in bytes.
	MaxBufferSize uint64
	// MaxVertexAttributes is the max vertex attributes in a pipeline.
	MaxVertexAttributes uint32
	// MaxVertexBufferArrayStride is the max vertex buffer array stride.
	MaxVertexBufferArrayStride uint32
	// MaxInterStageShaderVariables is the max inter-stage shader variables.
	MaxInterStageShaderVariables uint32
	// MaxColorAttachments is the max color attachments in a render pass.
	MaxColorAttachments uint32
	// MaxColorAttachmentBytesPerSample is the max bytes per sample for color attachments.
	MaxColorAttachmentBytesPerSample uint32
	// MaxComputeWorkgroupStorageSize is the max compute workgroup storage in bytes.
	MaxComputeWorkgroupStorageSize uint32
	// MaxComputeInvocationsPerWorkgroup is the max compute invocations per workgroup.
	MaxComputeInvocationsPerWorkgroup uint32
	// MaxComputeWorkgroupSizeX is the max compute workgroup size in X dimension.
	MaxComputeWorkgroupSizeX uint32
	// MaxComputeWorkgroupSizeY is the max compute workgroup size in Y dimension.
	MaxComputeWorkgroupSizeY uint32
	// MaxComputeWorkgroupSizeZ is the max compute workgroup size in Z dimension.
	MaxComputeWorkgroupSizeZ uint32
	// MaxComputeWorkgroupsPerDimension is the max compute workgroups per dimension.
	MaxComputeWorkgroupsPerDimension uint32
	// MaxPushConstantSize is the max push constant size in bytes (non-standard extension).
	MaxPushConstantSize uint32
	// MaxNonSamplerBindings is the max non-sampler bindings.
	MaxNonSamplerBindings uint32

	// MaxBlasPrimitiveCount is the max primitives per BLAS (0 = RT not supported).
	MaxBlasPrimitiveCount uint32
	// MaxBlasGeometryCount is the max geometries per BLAS.
	MaxBlasGeometryCount uint32
	// MaxTlasInstanceCount is the max instances per TLAS.
	MaxTlasInstanceCount uint32
	// MaxAccelerationStructuresPerShaderStage is the max AS bindings per shader stage.
	MaxAccelerationStructuresPerShaderStage uint32
	// MaxBuffersAndAccelerationStructuresPerShaderStage is the combined max
	// of storage buffers + AS bindings per shader stage.
	MaxBuffersAndAccelerationStructuresPerShaderStage uint32
	// MaxBindingArrayAccelerationStructureElementsPerShaderStage is the max AS
	// binding array elements per shader stage (requires FeatureASBindingArray).
	MaxBindingArrayAccelerationStructureElementsPerShaderStage uint32
	// MaxRayDispatchCount is the max dispatch dimensions for trace rays.
	MaxRayDispatchCount uint32
	// MaxRayRecursionDepth is the max ray recursion depth (RT pipelines only).
	MaxRayRecursionDepth uint32
}

Limits describes the GPU resource limits.

These limits define the maximum capabilities of a GPU device. The actual limits depend on the hardware and driver.

func DefaultLimits

func DefaultLimits() Limits

DefaultLimits returns the default WebGPU limits.

These are the minimum guaranteed limits per the WebGPU specification. Most hardware supports significantly higher limits.

func DownlevelDefaultLimits added in v0.7.0

func DownlevelDefaultLimits() Limits

DownlevelDefaultLimits returns more conservative limits for older hardware.

Use these limits for maximum compatibility with older GPUs or mobile devices.

type LoadOp

type LoadOp uint32

LoadOp describes the load operation for an attachment.

const (
	// LoadOpUndefined is an undefined load operation (invalid).
	LoadOpUndefined LoadOp = 0x00000000
	// LoadOpLoad loads the existing contents.
	LoadOpLoad LoadOp = 0x00000001
	// LoadOpClear clears the attachment to a specified value.
	LoadOpClear LoadOp = 0x00000002
)

func (LoadOp) String

func (op LoadOp) String() string

String returns the load operation name.

type MapMode

type MapMode uint32

MapMode describes the access mode for buffer mapping.

This is a bit flag type.

const (
	// MapModeNone indicates no mapping (invalid for map operations).
	MapModeNone MapMode = 0x00000000
	// MapModeRead maps the buffer for reading.
	MapModeRead MapMode = 0x00000001
	// MapModeWrite maps the buffer for writing.
	MapModeWrite MapMode = 0x00000002
)

type MemoryHints

type MemoryHints uint8

MemoryHints provides memory allocation hints for device creation.

const (
	// MemoryHintsPerformance optimizes for performance (may use more memory).
	MemoryHintsPerformance MemoryHints = iota
	// MemoryHintsMemoryUsage optimizes for low memory usage.
	MemoryHintsMemoryUsage
)

func (MemoryHints) String

func (h MemoryHints) String() string

String returns the memory hints name.

type MipmapFilterMode

type MipmapFilterMode uint32

MipmapFilterMode describes mipmap filtering.

const (
	// MipmapFilterModeUndefined is an undefined mipmap filter mode (invalid).
	MipmapFilterModeUndefined MipmapFilterMode = 0x00000000
	// MipmapFilterModeNearest selects the nearest mip level.
	MipmapFilterModeNearest MipmapFilterMode = 0x00000001
	// MipmapFilterModeLinear interpolates between mip levels.
	MipmapFilterModeLinear MipmapFilterMode = 0x00000002
)

func (MipmapFilterMode) String

func (m MipmapFilterMode) String() string

String returns the mipmap filter mode name.

type MultisampleState

type MultisampleState struct {
	// Count is the number of samples per pixel (1, 2, 4, 8, or 16).
	Count uint32
	// Mask is the sample mask (all bits set = all samples).
	Mask uint64
	// AlphaToCoverageEnabled enables alpha-to-coverage.
	AlphaToCoverageEnabled bool
}

MultisampleState describes multisampling state.

func DefaultMultisampleState

func DefaultMultisampleState() MultisampleState

DefaultMultisampleState returns a multisample state with no multisampling.

type Origin3D

type Origin3D struct {
	// X is the X coordinate.
	X uint32
	// Y is the Y coordinate.
	Y uint32
	// Z is the Z coordinate (or array layer for 2D array textures).
	Z uint32
}

Origin3D describes a 3D origin point.

It is used to specify the starting point for texture copy operations.

type PipelineLayoutDescriptor

type PipelineLayoutDescriptor struct {
	// Label is an optional debug label.
	Label string
	// BindGroupLayouts are handles to bind group layouts (implementation-specific).
	BindGroupLayouts []uintptr
	// PushConstantRanges describe push constant ranges (non-standard extension).
	PushConstantRanges []PushConstantRange
}

PipelineLayoutDescriptor describes a pipeline layout.

type PowerPreference

type PowerPreference uint8

PowerPreference specifies power consumption preference for adapter selection.

const (
	// PowerPreferenceNone has no preference (system default).
	PowerPreferenceNone PowerPreference = iota
	// PowerPreferenceLowPower prefers low power consumption (typically integrated GPU).
	PowerPreferenceLowPower
	// PowerPreferenceHighPerformance prefers high performance (typically discrete GPU).
	PowerPreferenceHighPerformance
)

func (PowerPreference) String

func (p PowerPreference) String() string

String returns the power preference name.

type PresentMode

type PresentMode uint32

PresentMode specifies how frames are presented to the display. Controls VSync behavior and tearing.

const (
	// PresentModeUndefined is an undefined present mode (invalid).
	PresentModeUndefined PresentMode = 0x00000000

	// PresentModeFifo presents frames in FIFO order with VSync.
	// No tearing. Supported on all platforms.
	// Also known as "VSync On".
	PresentModeFifo PresentMode = 0x00000001

	// PresentModeFifoRelaxed is like Fifo but allows tearing if frames
	// take longer than one vblank.
	// Also known as "Adaptive VSync".
	PresentModeFifoRelaxed PresentMode = 0x00000002

	// PresentModeImmediate presents frames immediately without waiting for vblank.
	// May cause tearing. Also known as "VSync Off".
	PresentModeImmediate PresentMode = 0x00000003

	// PresentModeMailbox uses a single-frame queue, replacing old frames.
	// No tearing. Also known as "Fast VSync".
	PresentModeMailbox PresentMode = 0x00000004
)

func (PresentMode) String

func (m PresentMode) String() string

String returns the string representation of PresentMode.

type PrimitiveState

type PrimitiveState struct {
	// Topology is the primitive topology.
	Topology PrimitiveTopology
	// StripIndexFormat is the index format for strip topologies (nil for non-strip).
	StripIndexFormat *IndexFormat
	// FrontFace is the front face winding order.
	FrontFace FrontFace
	// CullMode specifies which faces to cull.
	CullMode CullMode
	// UnclippedDepth enables unclipped depth (requires feature).
	UnclippedDepth bool
}

PrimitiveState describes primitive assembly state.

func DefaultPrimitiveState

func DefaultPrimitiveState() PrimitiveState

DefaultPrimitiveState returns a primitive state with WebGPU spec defaults.

This is equivalent to `PrimitiveState{}` — the zero value of PrimitiveState is already the WebGPU spec default because all enum fields (PrimitiveTopology, FrontFace, CullMode) have their zero value defined as the spec default. This function is provided for explicit call-site documentation and parity with other Default*State helpers.

See Rust wgpu's `PrimitiveState::default()` for the equivalent pattern.

type PrimitiveTopology

type PrimitiveTopology uint32

PrimitiveTopology describes how vertices form primitives.

The zero value is PrimitiveTopologyTriangleList, which matches the WebGPU spec default ( https://gpuweb.github.io/gpuweb/#enumdef-gpuprimitivetopology ). This means `PrimitiveState{}` is a fully valid WebGPU-spec-default primitive assembly configuration — no normalization pass is needed anywhere.

This is intentionally better than Rust wgpu's approach: Rust relies on `#[derive(Default)] #[default]` annotations to achieve the same result. We get it for free from Go's zero initialization rules.

const (
	// PrimitiveTopologyTriangleList renders groups of 3 vertices as triangles.
	// This is the zero value and WebGPU spec default.
	PrimitiveTopologyTriangleList PrimitiveTopology = 0
	// PrimitiveTopologyPointList renders each vertex as a point.
	PrimitiveTopologyPointList PrimitiveTopology = 1
	// PrimitiveTopologyLineList renders pairs of vertices as lines.
	PrimitiveTopologyLineList PrimitiveTopology = 2
	// PrimitiveTopologyLineStrip renders connected lines.
	PrimitiveTopologyLineStrip PrimitiveTopology = 3
	// PrimitiveTopologyTriangleStrip renders connected triangles.
	PrimitiveTopologyTriangleStrip PrimitiveTopology = 4
)

func (PrimitiveTopology) String

func (t PrimitiveTopology) String() string

String returns the topology name.

type ProgrammableStage

type ProgrammableStage struct {
	// Module is a handle to the shader module (implementation-specific).
	Module uintptr
	// EntryPoint is the entry point function name.
	EntryPoint string
	// Constants are pipeline-overridable constants.
	Constants map[string]float64
}

ProgrammableStage describes a programmable shader stage in a pipeline.

type PushConstantRange

type PushConstantRange struct {
	// Stages are the shader stages that can access this range.
	Stages ShaderStages
	// Start is the start offset in bytes.
	Start uint32
	// End is the end offset in bytes.
	End uint32
}

PushConstantRange describes a push constant range.

Note: Push constants are a non-standard extension (not in WebGPU spec).

type RenderPassColorAttachment

type RenderPassColorAttachment struct {
	// View is the texture view to render to (implementation-specific handle).
	View uintptr
	// ResolveTarget is the texture view for multisample resolve (0 if none).
	ResolveTarget uintptr
	// LoadOp describes how to load the attachment.
	LoadOp LoadOp
	// StoreOp describes how to store the attachment.
	StoreOp StoreOp
	// ClearValue is the clear color (used when LoadOp is Clear).
	ClearValue Color
}

RenderPassColorAttachment describes a color attachment for a render pass.

type RenderPassDepthStencilAttachment

type RenderPassDepthStencilAttachment struct {
	// View is the texture view (implementation-specific handle).
	View uintptr
	// DepthLoadOp describes how to load depth.
	DepthLoadOp LoadOp
	// DepthStoreOp describes how to store depth.
	DepthStoreOp StoreOp
	// DepthClearValue is the clear depth value.
	DepthClearValue float32
	// DepthReadOnly indicates if depth is read-only.
	DepthReadOnly bool
	// StencilLoadOp describes how to load stencil.
	StencilLoadOp LoadOp
	// StencilStoreOp describes how to store stencil.
	StencilStoreOp StoreOp
	// StencilClearValue is the clear stencil value.
	StencilClearValue uint32
	// StencilReadOnly indicates if stencil is read-only.
	StencilReadOnly bool
}

RenderPassDepthStencilAttachment describes a depth-stencil attachment.

type RenderPassDescriptor

type RenderPassDescriptor struct {
	// Label is an optional debug label.
	Label string
	// ColorAttachments are the color attachments.
	ColorAttachments []RenderPassColorAttachment
	// DepthStencilAttachment is the depth-stencil attachment (nil if none).
	DepthStencilAttachment *RenderPassDepthStencilAttachment
}

RenderPassDescriptor describes a render pass.

type RequestAdapterOptions

type RequestAdapterOptions struct {
	// PowerPreference indicates power consumption preference.
	PowerPreference PowerPreference
	// ForceFallbackAdapter forces the use of a fallback (software) adapter.
	ForceFallbackAdapter bool
	// CompatibleSurface is a handle to a surface the adapter must support (0 if none).
	CompatibleSurface uintptr
}

RequestAdapterOptions controls adapter selection.

type SamplerBinding

type SamplerBinding struct {
	// Sampler is a handle to the sampler (implementation-specific).
	Sampler uintptr
}

SamplerBinding binds a sampler to a binding slot.

type SamplerBindingLayout

type SamplerBindingLayout struct {
	// Type is the sampler binding type.
	Type SamplerBindingType
}

SamplerBindingLayout describes a sampler binding in a bind group layout.

type SamplerBindingType

type SamplerBindingType uint32

SamplerBindingType describes how a sampler is bound in a bind group.

const (
	// SamplerBindingTypeUndefined is undefined (invalid).
	SamplerBindingTypeUndefined SamplerBindingType = 0x00000000
	// SamplerBindingTypeFiltering supports filtered texture sampling.
	SamplerBindingTypeFiltering SamplerBindingType = 0x00000001
	// SamplerBindingTypeNonFiltering does not support filtering.
	SamplerBindingTypeNonFiltering SamplerBindingType = 0x00000002
	// SamplerBindingTypeComparison is for depth comparison sampling.
	SamplerBindingTypeComparison SamplerBindingType = 0x00000003
)

func (SamplerBindingType) String

func (t SamplerBindingType) String() string

String returns the sampler binding type name.

type SamplerDescriptor

type SamplerDescriptor struct {
	// Label is an optional debug label.
	Label string
	// AddressModeU is the U (X) coordinate addressing mode.
	AddressModeU AddressMode
	// AddressModeV is the V (Y) coordinate addressing mode.
	AddressModeV AddressMode
	// AddressModeW is the W (Z) coordinate addressing mode.
	AddressModeW AddressMode
	// MagFilter is the magnification filter (texture appears larger).
	MagFilter FilterMode
	// MinFilter is the minification filter (texture appears smaller).
	MinFilter FilterMode
	// MipmapFilter is the mipmap selection filter.
	MipmapFilter MipmapFilterMode
	// LodMinClamp is the minimum level of detail (0.0 = base level).
	LodMinClamp float32
	// LodMaxClamp is the maximum level of detail.
	LodMaxClamp float32
	// Compare is the comparison function for depth sampling (Undefined = none).
	Compare CompareFunction
	// MaxAnisotropy is the maximum anisotropic filtering level (1-16, 1 = disabled).
	MaxAnisotropy uint16
}

SamplerDescriptor describes a sampler.

func DefaultSamplerDescriptor

func DefaultSamplerDescriptor() SamplerDescriptor

DefaultSamplerDescriptor returns a sampler descriptor with sensible defaults.

The default uses:

  • ClampToEdge addressing
  • Nearest filtering
  • No mipmap filtering
  • No comparison
  • No anisotropic filtering

func LinearSamplerDescriptor

func LinearSamplerDescriptor() SamplerDescriptor

LinearSamplerDescriptor returns a sampler descriptor with linear filtering.

Suitable for smooth texture sampling.

type ScissorRect added in v0.8.0

type ScissorRect struct {
	// X is the left edge of the scissor rectangle in pixels.
	X uint32
	// Y is the top edge of the scissor rectangle in pixels.
	Y uint32
	// Width is the scissor rectangle width in pixels.
	Width uint32
	// Height is the scissor rectangle height in pixels.
	Height uint32
}

ScissorRect describes a scissor clipping rectangle.

Maps 1:1 to MTLScissorRect and SDL3 SDL_Rect. DX12 D3D12_RECT uses min/max corners; the backend converts.

type ShaderModel added in v0.7.0

type ShaderModel uint32

ShaderModel represents the collections of shader features a device supports if it supports less than WebGPU normally allows. Defined in terms of D3D's shader models.

const (
	// ShaderModelSm2 represents extremely limited shaders, including a total instruction limit.
	ShaderModelSm2 ShaderModel = 2
	// ShaderModelSm4 represents shaders missing minor features and storage images.
	ShaderModelSm4 ShaderModel = 4
	// ShaderModelSm5 represents WebGPU-level shader support (shader model 5).
	ShaderModelSm5 ShaderModel = 5
)

func (ShaderModel) String added in v0.7.0

func (sm ShaderModel) String() string

String returns the shader model name.

type ShaderModuleDescriptor

type ShaderModuleDescriptor struct {
	// Label is an optional debug label.
	Label string
	// Source is the shader source code.
	Source ShaderSource
}

ShaderModuleDescriptor describes a shader module.

type ShaderSource

type ShaderSource interface {
	// contains filtered or unexported methods
}

ShaderSource represents shader source code.

Implementations include:

  • ShaderSourceWGSL for WGSL source code
  • ShaderSourceSPIRV for SPIR-V bytecode
  • ShaderSourceGLSL for GLSL source code

type ShaderSourceGLSL

type ShaderSourceGLSL struct {
	// Code is the GLSL source code.
	Code string
	// Stage is the shader stage this GLSL code is for.
	Stage ShaderStage
	// Defines is a map of preprocessor defines.
	Defines map[string]string
}

ShaderSourceGLSL is GLSL shader source.

Note: GLSL support is backend-dependent and may not be available on all platforms.

type ShaderSourceSPIRV

type ShaderSourceSPIRV struct {
	// Code is the SPIR-V bytecode as 32-bit words.
	Code []uint32
}

ShaderSourceSPIRV is SPIR-V bytecode shader source.

type ShaderSourceWGSL

type ShaderSourceWGSL struct {
	// Code is the WGSL source code.
	Code string
}

ShaderSourceWGSL is WGSL (WebGPU Shading Language) shader source.

type ShaderStage

type ShaderStage uint32

ShaderStage represents a shader stage.

This is a bit flag type. Multiple stages can be combined with bitwise OR.

const (
	// ShaderStageNone represents no shader stage.
	ShaderStageNone ShaderStage = 0x00000000
	// ShaderStageVertex is the vertex shader stage.
	ShaderStageVertex ShaderStage = 0x00000001
	// ShaderStageFragment is the fragment (pixel) shader stage.
	ShaderStageFragment ShaderStage = 0x00000002
	// ShaderStageCompute is the compute shader stage.
	ShaderStageCompute ShaderStage = 0x00000004
)

func (ShaderStage) Contains

func (s ShaderStage) Contains(stage ShaderStage) bool

Contains returns true if the stage set contains the given stage.

func (ShaderStage) String

func (s ShaderStage) String() string

String returns the shader stage name(s).

type ShaderStages

type ShaderStages = ShaderStage

ShaderStages is an alias for ShaderStage for clarity when used as a flag set.

type StencilFaceState

type StencilFaceState struct {
	// Compare is the comparison function.
	Compare CompareFunction
	// FailOp is the operation on stencil test failure.
	FailOp StencilOperation
	// DepthFailOp is the operation on depth test failure.
	DepthFailOp StencilOperation
	// PassOp is the operation on both tests passing.
	PassOp StencilOperation
}

StencilFaceState describes stencil operations for a face.

func DefaultStencilFaceState

func DefaultStencilFaceState() StencilFaceState

DefaultStencilFaceState returns a stencil face state that always passes and keeps.

type StencilOperation

type StencilOperation uint32

StencilOperation describes a stencil operation.

const (
	// StencilOperationUndefined is an undefined stencil operation (invalid).
	StencilOperationUndefined StencilOperation = 0x00000000
	// StencilOperationKeep keeps the current value.
	StencilOperationKeep StencilOperation = 0x00000001
	// StencilOperationZero sets to zero.
	StencilOperationZero StencilOperation = 0x00000002
	// StencilOperationReplace replaces with reference value.
	StencilOperationReplace StencilOperation = 0x00000003
	// StencilOperationInvert inverts all bits.
	StencilOperationInvert StencilOperation = 0x00000004
	// StencilOperationIncrementClamp increments and clamps to maximum.
	StencilOperationIncrementClamp StencilOperation = 0x00000005
	// StencilOperationDecrementClamp decrements and clamps to zero.
	StencilOperationDecrementClamp StencilOperation = 0x00000006
	// StencilOperationIncrementWrap increments and wraps to zero.
	StencilOperationIncrementWrap StencilOperation = 0x00000007
	// StencilOperationDecrementWrap decrements and wraps to maximum.
	StencilOperationDecrementWrap StencilOperation = 0x00000008
)

func (StencilOperation) String

func (op StencilOperation) String() string

String returns the stencil operation name.

type StorageTextureAccess

type StorageTextureAccess uint32

StorageTextureAccess describes storage texture access mode.

const (
	// StorageTextureAccessUndefined is an undefined access mode (invalid).
	StorageTextureAccessUndefined StorageTextureAccess = 0x00000000
	// StorageTextureAccessWriteOnly allows write-only access.
	StorageTextureAccessWriteOnly StorageTextureAccess = 0x00000001
	// StorageTextureAccessReadOnly allows read-only access.
	StorageTextureAccessReadOnly StorageTextureAccess = 0x00000002
	// StorageTextureAccessReadWrite allows read-write access.
	StorageTextureAccessReadWrite StorageTextureAccess = 0x00000003
)

func (StorageTextureAccess) String

func (a StorageTextureAccess) String() string

String returns the storage texture access name.

type StorageTextureBindingLayout

type StorageTextureBindingLayout struct {
	// Access specifies the storage texture access mode.
	Access StorageTextureAccess
	// Format is the texture format.
	Format TextureFormat
	// ViewDimension is the texture view dimension.
	ViewDimension TextureViewDimension
}

StorageTextureBindingLayout describes a storage texture binding.

type StoreOp

type StoreOp uint32

StoreOp describes the store operation for an attachment.

const (
	// StoreOpUndefined is an undefined store operation (invalid).
	StoreOpUndefined StoreOp = 0x00000000
	// StoreOpStore stores the contents to memory.
	StoreOpStore StoreOp = 0x00000001
	// StoreOpDiscard discards the contents (for performance when not needed).
	StoreOpDiscard StoreOp = 0x00000002
)

func (StoreOp) String

func (op StoreOp) String() string

String returns the store operation name.

type SurfaceCapabilities

type SurfaceCapabilities struct {
	// Formats lists supported texture formats. First is preferred.
	Formats []TextureFormat

	// PresentModes lists supported presentation modes.
	PresentModes []PresentMode

	// AlphaModes lists supported alpha compositing modes.
	AlphaModes []CompositeAlphaMode

	// Usages is a bitflag of supported texture usages.
	Usages TextureUsage
}

SurfaceCapabilities describes what a surface supports with a given adapter.

type SurfaceConfiguration

type SurfaceConfiguration struct {
	// Usage specifies how the surface texture will be used.
	// TextureUsageRenderAttachment is always supported.
	Usage TextureUsage

	// Format is the texture format of the surface.
	// BGRA8Unorm and BGRA8UnormSrgb are guaranteed to be supported.
	Format TextureFormat

	// Width of the surface in pixels. Must be non-zero.
	Width uint32

	// Height of the surface in pixels. Must be non-zero.
	Height uint32

	// PresentMode controls VSync and frame presentation timing.
	PresentMode PresentMode

	// DesiredMaximumFrameLatency is the target number of frames in flight.
	// Typical values are 1-3. Default is usually 2.
	DesiredMaximumFrameLatency uint32

	// AlphaMode specifies how alpha is handled during compositing.
	AlphaMode CompositeAlphaMode

	// ViewFormats lists additional formats for texture views.
	// Only sRGB variants of the surface format are typically allowed.
	ViewFormats []TextureFormat
}

SurfaceConfiguration configures a surface for presentation.

type SurfaceStatus

type SurfaceStatus uint32

SurfaceStatus indicates the state of a surface texture acquisition.

const (
	// SurfaceStatusGood indicates no issues.
	SurfaceStatusGood SurfaceStatus = iota

	// SurfaceStatusSuboptimal indicates the surface works but should be reconfigured.
	SurfaceStatusSuboptimal

	// SurfaceStatusTimeout indicates texture acquisition timed out.
	SurfaceStatusTimeout

	// SurfaceStatusOutdated indicates the underlying surface changed.
	SurfaceStatusOutdated

	// SurfaceStatusLost indicates the surface was lost.
	SurfaceStatusLost

	// SurfaceStatusUnknown indicates status is unknown due to previous failure.
	SurfaceStatusUnknown
)

func (SurfaceStatus) String

func (s SurfaceStatus) String() string

String returns the string representation of SurfaceStatus.

type TextureAspect

type TextureAspect uint32

TextureAspect describes which aspects of a texture to access.

const (
	// TextureAspectUndefined is an undefined texture aspect (invalid).
	TextureAspectUndefined TextureAspect = 0x00000000
	// TextureAspectAll accesses all aspects (default).
	TextureAspectAll TextureAspect = 0x00000001
	// TextureAspectStencilOnly accesses only the stencil aspect.
	TextureAspectStencilOnly TextureAspect = 0x00000002
	// TextureAspectDepthOnly accesses only the depth aspect.
	TextureAspectDepthOnly TextureAspect = 0x00000003
)

func (TextureAspect) String

func (a TextureAspect) String() string

String returns the aspect name.

type TextureBindingLayout

type TextureBindingLayout struct {
	// SampleType is the texture sample type.
	SampleType TextureSampleType
	// ViewDimension is the texture view dimension.
	ViewDimension TextureViewDimension
	// Multisampled indicates if the texture is multisampled.
	Multisampled bool
}

TextureBindingLayout describes a texture binding in a bind group layout.

type TextureDataLayout

type TextureDataLayout struct {
	// Offset is the offset in bytes from the start of the data.
	Offset uint64
	// BytesPerRow is the number of bytes per row of texture data.
	// Must be a multiple of 256 for buffer-to-texture copies.
	BytesPerRow uint32
	// RowsPerImage is the number of rows per image for 3D textures.
	RowsPerImage uint32
}

TextureDataLayout describes the layout of texture data in memory.

type TextureDescriptor

type TextureDescriptor struct {
	// Label is an optional debug label.
	Label string
	// Size is the texture size.
	Size Extent3D
	// MipLevelCount is the number of mip levels (1 for no mipmapping).
	MipLevelCount uint32
	// SampleCount is the number of samples (1 for non-multisampled).
	SampleCount uint32
	// Dimension is the texture dimension.
	Dimension TextureDimension
	// Format is the texture format.
	Format TextureFormat
	// Usage describes how the texture will be used.
	Usage TextureUsage
	// ViewFormats lists compatible view formats (optional).
	ViewFormats []TextureFormat
}

TextureDescriptor describes a texture.

type TextureDimension

type TextureDimension uint32

TextureDimension describes texture dimensions.

const (
	// TextureDimensionUndefined is an undefined texture dimension (invalid).
	TextureDimensionUndefined TextureDimension = 0x00000000
	// TextureDimension1D is a 1D texture.
	TextureDimension1D TextureDimension = 0x00000001
	// TextureDimension2D is a 2D texture.
	TextureDimension2D TextureDimension = 0x00000002
	// TextureDimension3D is a 3D texture.
	TextureDimension3D TextureDimension = 0x00000003
)

func (TextureDimension) String

func (d TextureDimension) String() string

String returns the dimension name.

type TextureFormat

type TextureFormat uint32

TextureFormat describes the format of a texture.

This enum covers all texture formats defined in the WebGPU specification, including uncompressed, depth/stencil, and compressed formats.

const (
	// TextureFormatUndefined is an undefined format (invalid).
	// webgpu.h: WGPUTextureFormat_Undefined = 0x00000000
	TextureFormatUndefined TextureFormat = 0x00000000

	// 8-bit formats
	// TextureFormatR8Unorm is a single 8-bit normalized unsigned integer.
	TextureFormatR8Unorm TextureFormat = 0x00000001
	// TextureFormatR8Snorm is a single 8-bit normalized signed integer.
	TextureFormatR8Snorm TextureFormat = 0x00000002
	// TextureFormatR8Uint is a single 8-bit unsigned integer.
	TextureFormatR8Uint TextureFormat = 0x00000003
	// TextureFormatR8Sint is a single 8-bit signed integer.
	TextureFormatR8Sint TextureFormat = 0x00000004

	// 16-bit formats
	// TextureFormatR16Unorm is a single 16-bit normalized unsigned integer.
	TextureFormatR16Unorm TextureFormat = 0x00000005
	// TextureFormatR16Snorm is a single 16-bit normalized signed integer.
	TextureFormatR16Snorm TextureFormat = 0x00000006
	// TextureFormatR16Uint is a single 16-bit unsigned integer.
	TextureFormatR16Uint TextureFormat = 0x00000007
	// TextureFormatR16Sint is a single 16-bit signed integer.
	TextureFormatR16Sint TextureFormat = 0x00000008
	// TextureFormatR16Float is a single 16-bit float.
	TextureFormatR16Float TextureFormat = 0x00000009
	// TextureFormatRG8Unorm is two 8-bit normalized unsigned integers.
	TextureFormatRG8Unorm TextureFormat = 0x0000000A
	// TextureFormatRG8Snorm is two 8-bit normalized signed integers.
	TextureFormatRG8Snorm TextureFormat = 0x0000000B
	// TextureFormatRG8Uint is two 8-bit unsigned integers.
	TextureFormatRG8Uint TextureFormat = 0x0000000C
	// TextureFormatRG8Sint is two 8-bit signed integers.
	TextureFormatRG8Sint TextureFormat = 0x0000000D

	// 32-bit formats
	// TextureFormatR32Float is a single 32-bit float.
	TextureFormatR32Float TextureFormat = 0x0000000E
	// TextureFormatR32Uint is a single 32-bit unsigned integer.
	TextureFormatR32Uint TextureFormat = 0x0000000F
	// TextureFormatR32Sint is a single 32-bit signed integer.
	TextureFormatR32Sint TextureFormat = 0x00000010
	// TextureFormatRG16Unorm is two 16-bit normalized unsigned integers.
	TextureFormatRG16Unorm TextureFormat = 0x00000011
	// TextureFormatRG16Snorm is two 16-bit normalized signed integers.
	TextureFormatRG16Snorm TextureFormat = 0x00000012
	// TextureFormatRG16Uint is two 16-bit unsigned integers.
	TextureFormatRG16Uint TextureFormat = 0x00000013
	// TextureFormatRG16Sint is two 16-bit signed integers.
	TextureFormatRG16Sint TextureFormat = 0x00000014
	// TextureFormatRG16Float is two 16-bit floats.
	TextureFormatRG16Float TextureFormat = 0x00000015
	// TextureFormatRGBA8Unorm is four 8-bit normalized unsigned integers.
	TextureFormatRGBA8Unorm TextureFormat = 0x00000016
	// TextureFormatRGBA8UnormSrgb is four 8-bit normalized unsigned integers in sRGB.
	TextureFormatRGBA8UnormSrgb TextureFormat = 0x00000017
	// TextureFormatRGBA8Snorm is four 8-bit normalized signed integers.
	TextureFormatRGBA8Snorm TextureFormat = 0x00000018
	// TextureFormatRGBA8Uint is four 8-bit unsigned integers.
	TextureFormatRGBA8Uint TextureFormat = 0x00000019
	// TextureFormatRGBA8Sint is four 8-bit signed integers.
	TextureFormatRGBA8Sint TextureFormat = 0x0000001A
	// TextureFormatBGRA8Unorm is four 8-bit normalized unsigned integers (BGRA order).
	TextureFormatBGRA8Unorm TextureFormat = 0x0000001B
	// TextureFormatBGRA8UnormSrgb is four 8-bit normalized unsigned integers in sRGB (BGRA order).
	TextureFormatBGRA8UnormSrgb TextureFormat = 0x0000001C

	// Packed 32-bit formats
	// TextureFormatRGB10A2Uint is a packed 10-10-10-2 unsigned integer format.
	TextureFormatRGB10A2Uint TextureFormat = 0x0000001D
	// TextureFormatRGB10A2Unorm is a packed 10-10-10-2 normalized unsigned format.
	TextureFormatRGB10A2Unorm TextureFormat = 0x0000001E
	// TextureFormatRG11B10Ufloat is a packed 11-11-10 unsigned float format.
	TextureFormatRG11B10Ufloat TextureFormat = 0x0000001F
	// TextureFormatRGB9E5Ufloat is a packed 9-9-9-5 unsigned float format.
	TextureFormatRGB9E5Ufloat TextureFormat = 0x00000020

	// 64-bit formats
	// TextureFormatRG32Float is two 32-bit floats.
	TextureFormatRG32Float TextureFormat = 0x00000021
	// TextureFormatRG32Uint is two 32-bit unsigned integers.
	TextureFormatRG32Uint TextureFormat = 0x00000022
	// TextureFormatRG32Sint is two 32-bit signed integers.
	TextureFormatRG32Sint TextureFormat = 0x00000023
	// TextureFormatRGBA16Unorm is four 16-bit normalized unsigned integers.
	TextureFormatRGBA16Unorm TextureFormat = 0x00000024
	// TextureFormatRGBA16Snorm is four 16-bit normalized signed integers.
	TextureFormatRGBA16Snorm TextureFormat = 0x00000025
	// TextureFormatRGBA16Uint is four 16-bit unsigned integers.
	TextureFormatRGBA16Uint TextureFormat = 0x00000026
	// TextureFormatRGBA16Sint is four 16-bit signed integers.
	TextureFormatRGBA16Sint TextureFormat = 0x00000027
	// TextureFormatRGBA16Float is four 16-bit floats.
	TextureFormatRGBA16Float TextureFormat = 0x00000028

	// 128-bit formats
	// TextureFormatRGBA32Float is four 32-bit floats.
	TextureFormatRGBA32Float TextureFormat = 0x00000029
	// TextureFormatRGBA32Uint is four 32-bit unsigned integers.
	TextureFormatRGBA32Uint TextureFormat = 0x0000002A
	// TextureFormatRGBA32Sint is four 32-bit signed integers.
	TextureFormatRGBA32Sint TextureFormat = 0x0000002B

	// Depth/stencil formats
	// TextureFormatStencil8 is an 8-bit stencil format.
	TextureFormatStencil8 TextureFormat = 0x0000002C
	// TextureFormatDepth16Unorm is a 16-bit normalized depth format.
	TextureFormatDepth16Unorm TextureFormat = 0x0000002D
	// TextureFormatDepth24Plus is a 24-bit depth format (may be 32-bit internally).
	TextureFormatDepth24Plus TextureFormat = 0x0000002E
	// TextureFormatDepth24PlusStencil8 is a 24-bit depth + 8-bit stencil format.
	TextureFormatDepth24PlusStencil8 TextureFormat = 0x0000002F
	// TextureFormatDepth32Float is a 32-bit float depth format.
	TextureFormatDepth32Float TextureFormat = 0x00000030
	// TextureFormatDepth32FloatStencil8 is a 32-bit float depth + 8-bit stencil format.
	TextureFormatDepth32FloatStencil8 TextureFormat = 0x00000031

	// BC compressed formats (requires TextureCompressionBC feature)
	// webgpu.h: BC formats start at 0x32 (after depth/stencil formats)
	// TextureFormatBC1RGBAUnorm is BC1 RGBA normalized unsigned format.
	TextureFormatBC1RGBAUnorm TextureFormat = 0x00000032
	// TextureFormatBC1RGBAUnormSrgb is BC1 RGBA normalized unsigned sRGB format.
	TextureFormatBC1RGBAUnormSrgb TextureFormat = 0x00000033
	// TextureFormatBC2RGBAUnorm is BC2 RGBA normalized unsigned format.
	TextureFormatBC2RGBAUnorm TextureFormat = 0x00000034
	// TextureFormatBC2RGBAUnormSrgb is BC2 RGBA normalized unsigned sRGB format.
	TextureFormatBC2RGBAUnormSrgb TextureFormat = 0x00000035
	// TextureFormatBC3RGBAUnorm is BC3 RGBA normalized unsigned format.
	TextureFormatBC3RGBAUnorm TextureFormat = 0x00000036
	// TextureFormatBC3RGBAUnormSrgb is BC3 RGBA normalized unsigned sRGB format.
	TextureFormatBC3RGBAUnormSrgb TextureFormat = 0x00000037
	// TextureFormatBC4RUnorm is BC4 R normalized unsigned format.
	TextureFormatBC4RUnorm TextureFormat = 0x00000038
	// TextureFormatBC4RSnorm is BC4 R normalized signed format.
	TextureFormatBC4RSnorm TextureFormat = 0x00000039
	// TextureFormatBC5RGUnorm is BC5 RG normalized unsigned format.
	TextureFormatBC5RGUnorm TextureFormat = 0x0000003A
	// TextureFormatBC5RGSnorm is BC5 RG normalized signed format.
	TextureFormatBC5RGSnorm TextureFormat = 0x0000003B
	// TextureFormatBC6HRGBUfloat is BC6H RGB unsigned float format.
	TextureFormatBC6HRGBUfloat TextureFormat = 0x0000003C
	// TextureFormatBC6HRGBFloat is BC6H RGB signed float format.
	TextureFormatBC6HRGBFloat TextureFormat = 0x0000003D
	// TextureFormatBC7RGBAUnorm is BC7 RGBA normalized unsigned format.
	TextureFormatBC7RGBAUnorm TextureFormat = 0x0000003E
	// TextureFormatBC7RGBAUnormSrgb is BC7 RGBA normalized unsigned sRGB format.
	TextureFormatBC7RGBAUnormSrgb TextureFormat = 0x0000003F

	// ETC2 compressed formats (requires TextureCompressionETC2 feature)
	// webgpu.h: ETC2 formats start at 0x40 (after BC formats)
	// TextureFormatETC2RGB8Unorm is ETC2 RGB normalized unsigned format.
	TextureFormatETC2RGB8Unorm TextureFormat = 0x00000040
	// TextureFormatETC2RGB8UnormSrgb is ETC2 RGB normalized unsigned sRGB format.
	TextureFormatETC2RGB8UnormSrgb TextureFormat = 0x00000041
	// TextureFormatETC2RGB8A1Unorm is ETC2 RGB with 1-bit alpha normalized unsigned format.
	TextureFormatETC2RGB8A1Unorm TextureFormat = 0x00000042
	// TextureFormatETC2RGB8A1UnormSrgb is ETC2 RGB with 1-bit alpha normalized unsigned sRGB format.
	TextureFormatETC2RGB8A1UnormSrgb TextureFormat = 0x00000043
	// TextureFormatETC2RGBA8Unorm is ETC2 RGBA normalized unsigned format.
	TextureFormatETC2RGBA8Unorm TextureFormat = 0x00000044
	// TextureFormatETC2RGBA8UnormSrgb is ETC2 RGBA normalized unsigned sRGB format.
	TextureFormatETC2RGBA8UnormSrgb TextureFormat = 0x00000045
	// TextureFormatEACR11Unorm is EAC R normalized unsigned format.
	TextureFormatEACR11Unorm TextureFormat = 0x00000046
	// TextureFormatEACR11Snorm is EAC R normalized signed format.
	TextureFormatEACR11Snorm TextureFormat = 0x00000047
	// TextureFormatEACRG11Unorm is EAC RG normalized unsigned format.
	TextureFormatEACRG11Unorm TextureFormat = 0x00000048
	// TextureFormatEACRG11Snorm is EAC RG normalized signed format.
	TextureFormatEACRG11Snorm TextureFormat = 0x00000049

	// ASTC compressed formats (requires TextureCompressionASTC feature)
	// webgpu.h: ASTC formats start at 0x4A (after ETC2 formats)
	// TextureFormatASTC4x4Unorm is ASTC 4x4 normalized unsigned format.
	TextureFormatASTC4x4Unorm TextureFormat = 0x0000004A
	// TextureFormatASTC4x4UnormSrgb is ASTC 4x4 normalized unsigned sRGB format.
	TextureFormatASTC4x4UnormSrgb TextureFormat = 0x0000004B
	// TextureFormatASTC5x4Unorm is ASTC 5x4 normalized unsigned format.
	TextureFormatASTC5x4Unorm TextureFormat = 0x0000004C
	// TextureFormatASTC5x4UnormSrgb is ASTC 5x4 normalized unsigned sRGB format.
	TextureFormatASTC5x4UnormSrgb TextureFormat = 0x0000004D
	// TextureFormatASTC5x5Unorm is ASTC 5x5 normalized unsigned format.
	TextureFormatASTC5x5Unorm TextureFormat = 0x0000004E
	// TextureFormatASTC5x5UnormSrgb is ASTC 5x5 normalized unsigned sRGB format.
	TextureFormatASTC5x5UnormSrgb TextureFormat = 0x0000004F
	// TextureFormatASTC6x5Unorm is ASTC 6x5 normalized unsigned format.
	TextureFormatASTC6x5Unorm TextureFormat = 0x00000050
	// TextureFormatASTC6x5UnormSrgb is ASTC 6x5 normalized unsigned sRGB format.
	TextureFormatASTC6x5UnormSrgb TextureFormat = 0x00000051
	// TextureFormatASTC6x6Unorm is ASTC 6x6 normalized unsigned format.
	TextureFormatASTC6x6Unorm TextureFormat = 0x00000052
	// TextureFormatASTC6x6UnormSrgb is ASTC 6x6 normalized unsigned sRGB format.
	TextureFormatASTC6x6UnormSrgb TextureFormat = 0x00000053
	// TextureFormatASTC8x5Unorm is ASTC 8x5 normalized unsigned format.
	TextureFormatASTC8x5Unorm TextureFormat = 0x00000054
	// TextureFormatASTC8x5UnormSrgb is ASTC 8x5 normalized unsigned sRGB format.
	TextureFormatASTC8x5UnormSrgb TextureFormat = 0x00000055
	// TextureFormatASTC8x6Unorm is ASTC 8x6 normalized unsigned format.
	TextureFormatASTC8x6Unorm TextureFormat = 0x00000056
	// TextureFormatASTC8x6UnormSrgb is ASTC 8x6 normalized unsigned sRGB format.
	TextureFormatASTC8x6UnormSrgb TextureFormat = 0x00000057
	// TextureFormatASTC8x8Unorm is ASTC 8x8 normalized unsigned format.
	TextureFormatASTC8x8Unorm TextureFormat = 0x00000058
	// TextureFormatASTC8x8UnormSrgb is ASTC 8x8 normalized unsigned sRGB format.
	TextureFormatASTC8x8UnormSrgb TextureFormat = 0x00000059
	// TextureFormatASTC10x5Unorm is ASTC 10x5 normalized unsigned format.
	TextureFormatASTC10x5Unorm TextureFormat = 0x0000005A
	// TextureFormatASTC10x5UnormSrgb is ASTC 10x5 normalized unsigned sRGB format.
	TextureFormatASTC10x5UnormSrgb TextureFormat = 0x0000005B
	// TextureFormatASTC10x6Unorm is ASTC 10x6 normalized unsigned format.
	TextureFormatASTC10x6Unorm TextureFormat = 0x0000005C
	// TextureFormatASTC10x6UnormSrgb is ASTC 10x6 normalized unsigned sRGB format.
	TextureFormatASTC10x6UnormSrgb TextureFormat = 0x0000005D
	// TextureFormatASTC10x8Unorm is ASTC 10x8 normalized unsigned format.
	TextureFormatASTC10x8Unorm TextureFormat = 0x0000005E
	// TextureFormatASTC10x8UnormSrgb is ASTC 10x8 normalized unsigned sRGB format.
	TextureFormatASTC10x8UnormSrgb TextureFormat = 0x0000005F
	// TextureFormatASTC10x10Unorm is ASTC 10x10 normalized unsigned format.
	TextureFormatASTC10x10Unorm TextureFormat = 0x00000060
	// TextureFormatASTC10x10UnormSrgb is ASTC 10x10 normalized unsigned sRGB format.
	TextureFormatASTC10x10UnormSrgb TextureFormat = 0x00000061
	// TextureFormatASTC12x10Unorm is ASTC 12x10 normalized unsigned format.
	TextureFormatASTC12x10Unorm TextureFormat = 0x00000062
	// TextureFormatASTC12x10UnormSrgb is ASTC 12x10 normalized unsigned sRGB format.
	TextureFormatASTC12x10UnormSrgb TextureFormat = 0x00000063
	// TextureFormatASTC12x12Unorm is ASTC 12x12 normalized unsigned format.
	TextureFormatASTC12x12Unorm TextureFormat = 0x00000064
	// TextureFormatASTC12x12UnormSrgb is ASTC 12x12 normalized unsigned sRGB format.
	TextureFormatASTC12x12UnormSrgb TextureFormat = 0x00000065
)

func (TextureFormat) BlockCopySize added in v0.5.1

func (f TextureFormat) BlockCopySize() uint32

BlockCopySize returns the number of bytes occupied per texel block for this format.

For uncompressed formats, one block equals one texel. For compressed formats (BC, ETC2, ASTC), one block covers multiple texels (e.g. 4x4 for BC/ETC2, variable for ASTC), but the returned value is the byte size of that block.

Returns 0 for formats whose copy size is implementation-defined:

  • Depth24Plus
  • Depth24PlusStencil8
  • Depth32FloatStencil8

Returns 0 for unknown or invalid formats (including TextureFormatUndefined).

Reference: Rust wgpu-types TextureFormat::block_copy_size().

func (TextureFormat) HasDepth

func (f TextureFormat) HasDepth() bool

HasDepth returns true if this format has a depth component.

func (TextureFormat) HasStencil

func (f TextureFormat) HasStencil() bool

HasStencil returns true if this format has a stencil component.

func (TextureFormat) IsDepthStencil

func (f TextureFormat) IsDepthStencil() bool

IsDepthStencil returns true if this is a depth or stencil format.

func (TextureFormat) IsSrgb

func (f TextureFormat) IsSrgb() bool

IsSrgb returns true if this is an sRGB format.

func (TextureFormat) String

func (f TextureFormat) String() string

String returns the name of the texture format.

type TextureSampleType

type TextureSampleType uint32

TextureSampleType describes the sample type of a texture.

const (
	// TextureSampleTypeUndefined is an undefined sample type (invalid).
	TextureSampleTypeUndefined TextureSampleType = 0x00000000
	// TextureSampleTypeFloat samples as filterable floating-point.
	TextureSampleTypeFloat TextureSampleType = 0x00000001
	// TextureSampleTypeUnfilterableFloat samples as unfilterable floating-point.
	TextureSampleTypeUnfilterableFloat TextureSampleType = 0x00000002
	// TextureSampleTypeDepth samples as depth comparison.
	TextureSampleTypeDepth TextureSampleType = 0x00000003
	// TextureSampleTypeSint samples as signed integer.
	TextureSampleTypeSint TextureSampleType = 0x00000004
	// TextureSampleTypeUint samples as unsigned integer.
	TextureSampleTypeUint TextureSampleType = 0x00000005
)

func (TextureSampleType) String

func (t TextureSampleType) String() string

String returns the sample type name.

type TextureUsage

type TextureUsage uint64

TextureUsage describes how a texture can be used.

This is a bit flag type. Combine multiple usages with bitwise OR.

const (
	// TextureUsageNone indicates no usage (invalid for most operations).
	TextureUsageNone TextureUsage = 0x0000000000000000
	// TextureUsageCopySrc allows the texture to be a copy source.
	TextureUsageCopySrc TextureUsage = 0x0000000000000001
	// TextureUsageCopyDst allows the texture to be a copy destination.
	TextureUsageCopyDst TextureUsage = 0x0000000000000002
	// TextureUsageTextureBinding allows the texture to be bound as a sampled texture.
	TextureUsageTextureBinding TextureUsage = 0x0000000000000004
	// TextureUsageStorageBinding allows the texture to be bound as a storage texture.
	TextureUsageStorageBinding TextureUsage = 0x0000000000000008
	// TextureUsageRenderAttachment allows the texture to be used as a render attachment.
	TextureUsageRenderAttachment TextureUsage = 0x0000000000000010
)

func (TextureUsage) Contains

func (u TextureUsage) Contains(flag TextureUsage) bool

Contains returns true if the usage includes the given flag.

func (TextureUsage) ContainsUnknownBits added in v0.3.0

func (u TextureUsage) ContainsUnknownBits() bool

ContainsUnknownBits returns true if the usage contains any unknown flags.

type TextureViewBinding

type TextureViewBinding struct {
	// TextureView is a handle to the texture view (implementation-specific).
	TextureView uintptr
}

TextureViewBinding binds a texture view to a binding slot.

type TextureViewDescriptor

type TextureViewDescriptor struct {
	// Label is an optional debug label.
	Label string
	// Format is the view format (defaults to texture format if Undefined).
	Format TextureFormat
	// Dimension is the view dimension (defaults to match texture if Undefined).
	Dimension TextureViewDimension
	// Aspect specifies which aspect to view.
	Aspect TextureAspect
	// BaseMipLevel is the first mip level accessible to the view.
	BaseMipLevel uint32
	// MipLevelCount is the number of mip levels accessible (0 for all remaining).
	MipLevelCount uint32
	// BaseArrayLayer is the first array layer accessible to the view.
	BaseArrayLayer uint32
	// ArrayLayerCount is the number of array layers accessible (0 for all remaining).
	ArrayLayerCount uint32
}

TextureViewDescriptor describes a texture view.

type TextureViewDimension

type TextureViewDimension uint32

TextureViewDimension describes a texture view dimension.

const (
	// TextureViewDimensionUndefined uses the same dimension as the texture.
	TextureViewDimensionUndefined TextureViewDimension = 0x00000000
	// TextureViewDimension1D is a 1D texture view.
	TextureViewDimension1D TextureViewDimension = 0x00000001
	// TextureViewDimension2D is a 2D texture view.
	TextureViewDimension2D TextureViewDimension = 0x00000002
	// TextureViewDimension2DArray is a 2D array texture view.
	TextureViewDimension2DArray TextureViewDimension = 0x00000003
	// TextureViewDimensionCube is a cube texture view.
	TextureViewDimensionCube TextureViewDimension = 0x00000004
	// TextureViewDimensionCubeArray is a cube array texture view.
	TextureViewDimensionCubeArray TextureViewDimension = 0x00000005
	// TextureViewDimension3D is a 3D texture view.
	TextureViewDimension3D TextureViewDimension = 0x00000006
)

func (TextureViewDimension) String

func (d TextureViewDimension) String() string

String returns the view dimension name.

type VertexAttribute

type VertexAttribute struct {
	// Format is the attribute format.
	Format VertexFormat
	// Offset is the byte offset within the vertex buffer stride.
	Offset uint64
	// ShaderLocation is the @location in the shader.
	ShaderLocation uint32
}

VertexAttribute describes a vertex attribute in a vertex buffer layout.

type VertexBufferLayout

type VertexBufferLayout struct {
	// ArrayStride is the stride between vertices in bytes.
	ArrayStride uint64
	// StepMode describes how the buffer is stepped.
	StepMode VertexStepMode
	// Attributes are the vertex attributes.
	Attributes []VertexAttribute
}

VertexBufferLayout describes the layout of a vertex buffer.

type VertexFormat

type VertexFormat uint32

VertexFormat describes a vertex attribute format.

The format name follows the pattern: TypeSizex[Count] where Type is the data type, Size is the bit width, and Count is the number of components.

const (
	// VertexFormatUndefined is an undefined vertex format (invalid).
	VertexFormatUndefined VertexFormat = 0x00000000
	// VertexFormatUint8x2 is two 8-bit unsigned integers.
	VertexFormatUint8x2 VertexFormat = 0x00000001
	// VertexFormatUint8x4 is four 8-bit unsigned integers.
	VertexFormatUint8x4 VertexFormat = 0x00000002
	// VertexFormatSint8x2 is two 8-bit signed integers.
	VertexFormatSint8x2 VertexFormat = 0x00000003
	// VertexFormatSint8x4 is four 8-bit signed integers.
	VertexFormatSint8x4 VertexFormat = 0x00000004
	// VertexFormatUnorm8x2 is two 8-bit normalized unsigned integers [0.0, 1.0].
	VertexFormatUnorm8x2 VertexFormat = 0x00000005
	// VertexFormatUnorm8x4 is four 8-bit normalized unsigned integers [0.0, 1.0].
	VertexFormatUnorm8x4 VertexFormat = 0x00000006
	// VertexFormatSnorm8x2 is two 8-bit normalized signed integers [-1.0, 1.0].
	VertexFormatSnorm8x2 VertexFormat = 0x00000007
	// VertexFormatSnorm8x4 is four 8-bit normalized signed integers [-1.0, 1.0].
	VertexFormatSnorm8x4 VertexFormat = 0x00000008
	// VertexFormatUint16x2 is two 16-bit unsigned integers.
	VertexFormatUint16x2 VertexFormat = 0x00000009
	// VertexFormatUint16x4 is four 16-bit unsigned integers.
	VertexFormatUint16x4 VertexFormat = 0x0000000A
	// VertexFormatSint16x2 is two 16-bit signed integers.
	VertexFormatSint16x2 VertexFormat = 0x0000000B
	// VertexFormatSint16x4 is four 16-bit signed integers.
	VertexFormatSint16x4 VertexFormat = 0x0000000C
	// VertexFormatUnorm16x2 is two 16-bit normalized unsigned integers [0.0, 1.0].
	VertexFormatUnorm16x2 VertexFormat = 0x0000000D
	// VertexFormatUnorm16x4 is four 16-bit normalized unsigned integers [0.0, 1.0].
	VertexFormatUnorm16x4 VertexFormat = 0x0000000E
	// VertexFormatSnorm16x2 is two 16-bit normalized signed integers [-1.0, 1.0].
	VertexFormatSnorm16x2 VertexFormat = 0x0000000F
	// VertexFormatSnorm16x4 is four 16-bit normalized signed integers [-1.0, 1.0].
	VertexFormatSnorm16x4 VertexFormat = 0x00000010
	// VertexFormatFloat16x2 is two 16-bit floats.
	VertexFormatFloat16x2 VertexFormat = 0x00000011
	// VertexFormatFloat16x4 is four 16-bit floats.
	VertexFormatFloat16x4 VertexFormat = 0x00000012
	// VertexFormatFloat32 is a single 32-bit float.
	VertexFormatFloat32 VertexFormat = 0x00000013
	// VertexFormatFloat32x2 is two 32-bit floats (vec2).
	VertexFormatFloat32x2 VertexFormat = 0x00000014
	// VertexFormatFloat32x3 is three 32-bit floats (vec3).
	VertexFormatFloat32x3 VertexFormat = 0x00000015
	// VertexFormatFloat32x4 is four 32-bit floats (vec4).
	VertexFormatFloat32x4 VertexFormat = 0x00000016
	// VertexFormatUint32 is a single 32-bit unsigned integer.
	VertexFormatUint32 VertexFormat = 0x00000017
	// VertexFormatUint32x2 is two 32-bit unsigned integers.
	VertexFormatUint32x2 VertexFormat = 0x00000018
	// VertexFormatUint32x3 is three 32-bit unsigned integers.
	VertexFormatUint32x3 VertexFormat = 0x00000019
	// VertexFormatUint32x4 is four 32-bit unsigned integers.
	VertexFormatUint32x4 VertexFormat = 0x0000001A
	// VertexFormatSint32 is a single 32-bit signed integer.
	VertexFormatSint32 VertexFormat = 0x0000001B
	// VertexFormatSint32x2 is two 32-bit signed integers.
	VertexFormatSint32x2 VertexFormat = 0x0000001C
	// VertexFormatSint32x3 is three 32-bit signed integers.
	VertexFormatSint32x3 VertexFormat = 0x0000001D
	// VertexFormatSint32x4 is four 32-bit signed integers.
	VertexFormatSint32x4 VertexFormat = 0x0000001E
	// VertexFormatUnorm1010102 is a packed 10-10-10-2 normalized unsigned format.
	VertexFormatUnorm1010102 VertexFormat = 0x0000001F
)

func (VertexFormat) Size

func (f VertexFormat) Size() uint64

Size returns the byte size of the vertex format.

func (VertexFormat) String

func (f VertexFormat) String() string

String returns the vertex format name.

type VertexState

type VertexState struct {
	// Module is a handle to the shader module (implementation-specific).
	Module uintptr
	// EntryPoint is the vertex shader entry point function name.
	EntryPoint string
	// Constants are pipeline-overridable constants.
	Constants map[string]float64
	// Buffers are the vertex buffer layouts.
	Buffers []VertexBufferLayout
}

VertexState describes the vertex stage of a render pipeline.

type VertexStepMode

type VertexStepMode uint32

VertexStepMode describes how vertex data is stepped.

const (
	// VertexStepModeUndefined is an undefined step mode (invalid).
	VertexStepModeUndefined VertexStepMode = 0x00000000
	// VertexStepModeVertexBufferNotUsed indicates the buffer is not used.
	VertexStepModeVertexBufferNotUsed VertexStepMode = 0x00000001
	// VertexStepModeVertex steps once per vertex.
	VertexStepModeVertex VertexStepMode = 0x00000002
	// VertexStepModeInstance steps once per instance.
	VertexStepModeInstance VertexStepMode = 0x00000003
)

func (VertexStepMode) String

func (m VertexStepMode) String() string

String returns the step mode name.

type Viewport added in v0.8.0

type Viewport struct {
	// X is the left edge of the viewport in pixels.
	X float32
	// Y is the top edge of the viewport in pixels.
	Y float32
	// Width is the viewport width in pixels.
	Width float32
	// Height is the viewport height in pixels.
	Height float32
	// MinDepth is the minimum depth value (typically 0).
	MinDepth float32
	// MaxDepth is the maximum depth value (typically 1).
	MaxDepth float32
}

Viewport describes viewport transformation parameters.

Maps 1:1 to VkViewport, MTLViewport, D3D12_VIEWPORT. All native GPU APIs use a struct for viewport; the WebGPU JS spec uses positional params because JavaScript lacks cheap value types. Go has value types, so a struct is the Go-idiomatic choice.

Jump to

Keyboard shortcuts

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