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.
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
- Variables
- type AdapterInfo
- type AddressMode
- type Backend
- type Backends
- type BindGroupDescriptor
- type BindGroupEntry
- type BindGroupLayoutDescriptor
- type BindGroupLayoutEntry
- type BindingResource
- type BlendComponent
- type BlendFactor
- type BlendOperation
- type BlendState
- type BufferBinding
- type BufferBindingLayout
- type BufferBindingType
- type BufferDescriptor
- type BufferMapState
- type BufferUsage
- type Color
- type ColorTargetState
- type ColorWriteMask
- type CompareFunction
- type CompositeAlphaMode
- type CullMode
- type DepthStencilState
- type DeviceDescriptor
- type DeviceType
- type Dx12ShaderCompiler
- type Extent3D
- type Feature
- type Features
- func (f Features) Contains(feature Feature) bool
- func (f Features) ContainsAll(other Features) bool
- func (f Features) Count() int
- func (f *Features) Insert(feature Feature)
- func (f Features) Intersect(other Features) Features
- func (f Features) IsEmpty() bool
- func (f *Features) Remove(feature Feature)
- func (f Features) Union(other Features) Features
- type FilterMode
- type FragmentState
- type FrontFace
- type GLBackend
- type ImageCopyTexture
- type ImageSubresourceRange
- type IndexFormat
- type InstanceDescriptor
- type InstanceFlags
- type Limits
- type LoadOp
- type MapMode
- type MemoryHints
- type MipmapFilterMode
- type MultisampleState
- type Origin3D
- type PipelineLayoutDescriptor
- type PowerPreference
- type PresentMode
- type PrimitiveState
- type PrimitiveTopology
- type ProgrammableStage
- type PushConstantRange
- type RenderPassColorAttachment
- type RenderPassDepthStencilAttachment
- type RenderPassDescriptor
- type RequestAdapterOptions
- type SamplerBinding
- type SamplerBindingLayout
- type SamplerBindingType
- type SamplerDescriptor
- type ShaderModuleDescriptor
- type ShaderSource
- type ShaderSourceGLSL
- type ShaderSourceSPIRV
- type ShaderSourceWGSL
- type ShaderStage
- type ShaderStages
- type StencilFaceState
- type StencilOperation
- type StorageTextureAccess
- type StorageTextureBindingLayout
- type StoreOp
- type SurfaceCapabilities
- type SurfaceConfiguration
- type SurfaceStatus
- type TextureAspect
- type TextureBindingLayout
- type TextureDataLayout
- type TextureDescriptor
- type TextureDimension
- type TextureFormat
- type TextureSampleType
- type TextureUsage
- type TextureViewBinding
- type TextureViewDescriptor
- type TextureViewDimension
- type VertexAttribute
- type VertexBufferLayout
- type VertexFormat
- type VertexState
- type VertexStepMode
Constants ¶
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 ¶
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.
var OriginZero = Origin3D{X: 0, Y: 0, Z: 0}
OriginZero is the origin at (0, 0, 0).
Functions ¶
This section is empty.
Types ¶
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 )
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 )
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
}
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 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).
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 )
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 NewColorRGB ¶
NewColorRGB creates a new opaque Color with the given RGB values and alpha=1.0.
func (Color) Premultiplied ¶
Premultiplied returns the color with RGB components multiplied by alpha.
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 CullMode ¶
type CullMode uint32
CullMode describes which faces to cull.
const ( // CullModeUndefined is an undefined cull mode (invalid). CullModeUndefined CullMode = 0x00000000 // CullModeNone culls no faces. CullModeNone CullMode = 0x00000001 // CullModeFront culls front faces. CullModeFront CullMode = 0x00000002 // CullModeBack culls back faces. CullModeBack CullMode = 0x00000003 )
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 )
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 ¶
NewExtent2D creates an Extent3D for a 2D texture with 1 layer.
func NewExtent3D ¶
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 )
type Features ¶
type Features uint64
Features is a set of feature flags.
func (Features) ContainsAll ¶
ContainsAll checks if the feature set contains all specified features.
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 )
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.
const ( // FrontFaceUndefined is an undefined front face (invalid). FrontFaceUndefined FrontFace = 0x00000000 // FrontFaceCCW treats counter-clockwise vertices as front-facing. FrontFaceCCW FrontFace = 0x00000001 // FrontFaceCW treats clockwise vertices as front-facing. FrontFaceCW FrontFace = 0x00000002 )
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
}
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 DownlevelLimits ¶
func DownlevelLimits() Limits
DownlevelLimits returns more conservative limits for older hardware.
Use these limits for maximum compatibility with older GPUs or mobile devices.
type MapMode ¶
type MapMode uint32
MapMode describes the access mode for buffer mapping.
This is a bit flag type.
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 common defaults.
type PrimitiveTopology ¶
type PrimitiveTopology uint32
PrimitiveTopology describes how vertices form primitives.
const ( // PrimitiveTopologyUndefined is an undefined topology (invalid). PrimitiveTopologyUndefined PrimitiveTopology = 0x00000000 // PrimitiveTopologyPointList renders each vertex as a point. PrimitiveTopologyPointList PrimitiveTopology = 0x00000001 // PrimitiveTopologyLineList renders pairs of vertices as lines. PrimitiveTopologyLineList PrimitiveTopology = 0x00000002 // PrimitiveTopologyLineStrip renders connected lines. PrimitiveTopologyLineStrip PrimitiveTopology = 0x00000003 // PrimitiveTopologyTriangleList renders groups of 3 vertices as triangles. PrimitiveTopologyTriangleList PrimitiveTopology = 0x00000004 // PrimitiveTopologyTriangleStrip renders connected triangles. PrimitiveTopologyTriangleStrip PrimitiveTopology = 0x00000005 )
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 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 )
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) 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.
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.