Documentation
¶
Overview ¶
Package types defines WebGPU types that are backend-agnostic.
This package is a pure Go port of wgpu-types from the Rust wgpu project. It provides the fundamental types used by WebGPU:
- Backend and adapter types (BackendType, AdapterInfo)
- Resource types (Buffer, Texture, Sampler)
- Pipeline types (BindGroup, Pipeline, RenderPass)
- Descriptor types (BufferDescriptor, TextureDescriptor, etc.)
- Enums and constants (TextureFormat, CompareFunction, etc.)
These types are designed to be serializable and can be used for:
- Shader reflection
- Resource management
- State tracking
- Configuration
Reference: https://github.com/gfx-rs/wgpu/tree/trunk/wgpu-types
Index ¶
- Constants
- Variables
- type AdapterInfo
- type AddressMode
- type Backend
- type Backends
- type BindGroupDescriptor
- type BindGroupEntry
- type BindGroupLayoutDescriptor
- type BindGroupLayoutEntry
- type BindGroupLayoutHandle
- type BindingResource
- type BlendComponent
- type BlendFactor
- type BlendOperation
- type BlendState
- type BufferBinding
- type BufferBindingLayout
- type BufferBindingType
- type BufferDescriptor
- type BufferHandle
- type BufferMapState
- type BufferUsage
- type Color
- type ColorTargetState
- type ColorWriteMask
- type CompareFunction
- type CullMode
- type DeviceDescriptor
- type DeviceType
- type Dx12ShaderCompiler
- type Extent3D
- type Feature
- type Features
- type FilterMode
- type FrontFace
- type GlBackend
- type ImageCopyTexture
- 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 PrimitiveState
- type PrimitiveTopology
- type ProgrammableStage
- type PushConstantRange
- type QuerySetHandle
- type RenderPassColorAttachment
- type RenderPassDepthStencilAttachment
- type RenderPassDescriptor
- type RenderPassTimestampWrites
- type RequestAdapterOptions
- type SamplerBinding
- type SamplerBindingLayout
- type SamplerBindingType
- type SamplerDescriptor
- type SamplerHandle
- type ShaderModuleDescriptor
- type ShaderSource
- type ShaderSourceGLSL
- type ShaderSourceSPIRV
- type ShaderSourceWGSL
- type ShaderStage
- type ShaderStages
- type StorageTextureAccess
- type StorageTextureBindingLayout
- type StoreOp
- type Surface
- type TextureAspect
- type TextureBindingLayout
- type TextureDataLayout
- type TextureDescriptor
- type TextureDimension
- type TextureFormat
- type TextureSampleType
- type TextureUsage
- type TextureViewBinding
- type TextureViewDescriptor
- type TextureViewDimension
- type TextureViewHandle
- type VertexAttribute
- type VertexBufferLayout
- type VertexFormat
- type VertexState
- type VertexStepMode
Constants ¶
const ( // 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. BackendsGL Backends = 1 << BackendGL // BackendsBrowserWebGPU includes browser WebGPU. BackendsBrowserWebGPU Backends = 1 << BackendBrowserWebGPU // BackendsPrimary includes Vulkan, Metal, DX12, and browser WebGPU. BackendsPrimary = BackendsVulkan | BackendsMetal | BackendsDX12 | BackendsBrowserWebGPU // BackendsSecondary includes only GL (fallback). BackendsSecondary = BackendsGL // BackendsAll includes all backends. BackendsAll = BackendsPrimary | BackendsSecondary )
const ( // ShaderStagesVertexFragment includes vertex and fragment. ShaderStagesVertexFragment = ShaderStageVertex | ShaderStageFragment // ShaderStagesAll includes all stages. ShaderStagesAll = ShaderStageVertex | ShaderStageFragment | ShaderStageCompute )
Variables ¶
var ( ColorTransparent = Color{0, 0, 0, 0} ColorBlack = Color{0, 0, 0, 1} ColorWhite = Color{1, 1, 1, 1} ColorRed = Color{1, 0, 0, 1} ColorGreen = Color{0, 1, 0, 1} ColorBlue = Color{0, 0, 1, 1} )
PredefinedColors
Functions ¶
This section is empty.
Types ¶
type AdapterInfo ¶
type AdapterInfo struct {
// Name is the name of the adapter (e.g., "NVIDIA GeForce RTX 3080").
Name string
// Vendor is the adapter vendor (e.g., "NVIDIA").
Vendor string
// VendorID is the PCI vendor ID.
VendorID uint32
// DeviceID is the PCI device ID.
DeviceID uint32
// DeviceType indicates the type of GPU.
DeviceType DeviceType
// Driver is the driver version.
Driver string
// DriverInfo is additional driver information.
DriverInfo string
// Backend is the graphics backend in use.
Backend Backend
}
AdapterInfo contains information about a GPU adapter.
type AddressMode ¶
type AddressMode uint8
AddressMode describes texture coordinate addressing.
const ( // AddressModeClampToEdge clamps to the edge texel. AddressModeClampToEdge AddressMode = iota // AddressModeRepeat repeats the texture. AddressModeRepeat // AddressModeMirrorRepeat repeats with mirroring. AddressModeMirrorRepeat )
type Backend ¶
type Backend uint8
Backend identifies the GPU 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 BindGroupDescriptor ¶
type BindGroupDescriptor struct {
// Label is a debug label.
Label string
// Layout is the bind group layout.
Layout BindGroupLayoutHandle
// 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 a 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.
Binding uint32
// Visibility specifies which shader stages can access this binding.
Visibility ShaderStages
// Type describes the binding type (one of the following must be set).
Buffer *BufferBindingLayout
Sampler *SamplerBindingLayout
Texture *TextureBindingLayout
Storage *StorageTextureBindingLayout
}
BindGroupLayoutEntry describes a single binding in a bind group layout.
type BindingResource ¶
type BindingResource interface {
// contains filtered or unexported methods
}
BindingResource is a resource that can be bound.
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.
type BlendFactor ¶
type BlendFactor uint8
BlendFactor describes a blend factor.
const ( BlendFactorZero BlendFactor = iota BlendFactorOne BlendFactorSrc BlendFactorOneMinusSrc BlendFactorSrcAlpha BlendFactorOneMinusSrcAlpha BlendFactorDst BlendFactorOneMinusDst BlendFactorDstAlpha BlendFactorOneMinusDstAlpha BlendFactorSrcAlphaSaturated BlendFactorConstant BlendFactorOneMinusConstant )
type BlendOperation ¶
type BlendOperation uint8
BlendOperation describes a blend operation.
const ( BlendOperationAdd BlendOperation = iota BlendOperationSubtract BlendOperationReverseSubtract BlendOperationMin BlendOperationMax )
type BlendState ¶
type BlendState struct {
// Color describes color channel blending.
Color BlendComponent
// Alpha describes alpha channel blending.
Alpha BlendComponent
}
BlendState describes color blending.
type BufferBinding ¶
type BufferBinding struct {
// Buffer is the buffer handle.
Buffer BufferHandle
// Offset is the byte offset into the buffer.
Offset uint64
// Size is the byte size of the binding (0 for entire buffer).
Size uint64
}
BufferBinding binds a buffer range.
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.
MinBindingSize uint64
}
BufferBindingLayout describes a buffer binding.
type BufferBindingType ¶
type BufferBindingType uint8
BufferBindingType describes how a buffer is bound.
const ( // BufferBindingTypeUndefined is an undefined binding type. BufferBindingTypeUndefined BufferBindingType = iota // BufferBindingTypeUniform binds as a uniform buffer. BufferBindingTypeUniform // BufferBindingTypeStorage binds as a storage buffer (read-write). BufferBindingTypeStorage // BufferBindingTypeReadOnlyStorage binds as a read-only storage buffer. BufferBindingTypeReadOnlyStorage )
type BufferDescriptor ¶
type BufferDescriptor struct {
// Label is a 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 is mapped at creation.
MappedAtCreation bool
}
BufferDescriptor describes a buffer.
type BufferMapState ¶
type BufferMapState uint8
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 mapped. BufferMapStateMapped )
type BufferUsage ¶
type BufferUsage uint32
BufferUsage describes how a buffer can be used.
const ( // BufferUsageMapRead allows mapping the buffer for reading. BufferUsageMapRead BufferUsage = 1 << iota // BufferUsageMapWrite allows mapping the buffer for writing. BufferUsageMapWrite // BufferUsageCopySrc allows the buffer to be a copy source. BufferUsageCopySrc // BufferUsageCopyDst allows the buffer to be a copy destination. BufferUsageCopyDst // BufferUsageIndex allows use as an index buffer. BufferUsageIndex // BufferUsageVertex allows use as a vertex buffer. BufferUsageVertex // BufferUsageUniform allows use as a uniform buffer. BufferUsageUniform // BufferUsageStorage allows use as a storage buffer. BufferUsageStorage // BufferUsageIndirect allows use for indirect draw/dispatch. BufferUsageIndirect // BufferUsageQueryResolve allows use for query result resolution. BufferUsageQueryResolve )
type ColorTargetState ¶
type ColorTargetState struct {
// Format is the texture format.
Format TextureFormat
// Blend describes color blending (nil for no blending).
Blend *BlendState
// WriteMask specifies which channels to write.
WriteMask ColorWriteMask
}
ColorTargetState describes a color target in a render pipeline.
type ColorWriteMask ¶
type ColorWriteMask uint8
ColorWriteMask describes which color channels to write.
const ( ColorWriteMaskRed ColorWriteMask = 1 << iota ColorWriteMaskGreen ColorWriteMaskBlue ColorWriteMaskAlpha ColorWriteMaskAll = ColorWriteMaskRed | ColorWriteMaskGreen | ColorWriteMaskBlue | ColorWriteMaskAlpha )
type CompareFunction ¶
type CompareFunction uint8
CompareFunction describes a comparison function.
const ( // CompareFunctionUndefined is undefined (no comparison). CompareFunctionUndefined CompareFunction = iota // CompareFunctionNever always fails. CompareFunctionNever // CompareFunctionLess passes if source < destination. CompareFunctionLess // CompareFunctionEqual passes if source == destination. CompareFunctionEqual // CompareFunctionLessEqual passes if source <= destination. CompareFunctionLessEqual // CompareFunctionGreater passes if source > destination. CompareFunctionGreater // CompareFunctionNotEqual passes if source != destination. CompareFunctionNotEqual // CompareFunctionGreaterEqual passes if source >= destination. CompareFunctionGreaterEqual // CompareFunctionAlways always passes. CompareFunctionAlways )
type DeviceDescriptor ¶
type DeviceDescriptor struct {
// Label is a debug label for the device.
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 device.
func DefaultDeviceDescriptor ¶
func DefaultDeviceDescriptor() DeviceDescriptor
DefaultDeviceDescriptor returns the default device descriptor.
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.
const ( // Dx12ShaderCompilerFxc uses the legacy FXC compiler. Dx12ShaderCompilerFxc Dx12ShaderCompiler = iota // Dx12ShaderCompilerDxc uses the modern DXC compiler. Dx12ShaderCompilerDxc )
type Extent3D ¶
type Extent3D struct {
// Width is the size in the X dimension.
Width uint32
// Height is the size in the Y dimension.
Height uint32
// DepthOrArrayLayers is the size in Z or array layer count.
DepthOrArrayLayers uint32
}
Extent3D describes a 3D size.
type Feature ¶
type Feature uint64
Feature represents a WebGPU feature flag.
const ( // FeatureDepthClipControl enables depth clip control. FeatureDepthClipControl Feature = 1 << iota // FeatureDepth32FloatStencil8 enables depth32float-stencil8 format. FeatureDepth32FloatStencil8 // FeatureTextureCompressionBC enables BC texture compression. FeatureTextureCompressionBC // FeatureTextureCompressionETC2 enables ETC2 texture compression. FeatureTextureCompressionETC2 // FeatureTextureCompressionASTC enables ASTC texture compression. FeatureTextureCompressionASTC // FeatureIndirectFirstInstance enables indirect draw first instance. FeatureIndirectFirstInstance // FeatureShaderF16 enables f16 in shaders. FeatureShaderF16 // FeatureRG11B10UfloatRenderable enables RG11B10Ufloat as render target. FeatureRG11B10UfloatRenderable // FeatureBGRA8UnormStorage enables BGRA8Unorm as storage texture. 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 count. FeatureMultiDrawIndirectCount // FeaturePushConstants enables push constants. FeaturePushConstants // FeatureTextureAdapterSpecificFormatFeatures enables adapter-specific formats. FeatureTextureAdapterSpecificFormatFeatures // FeatureShaderFloat64 enables f64 in shaders. FeatureShaderFloat64 // FeatureVertexAttribute64bit enables 64-bit vertex attributes. FeatureVertexAttribute64bit // FeatureSubgroupOperations enables subgroup operations in shaders. FeatureSubgroupOperations // FeatureSubgroupBarrier enables subgroup barriers. 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 uint8
FilterMode describes texture filtering.
const ( // FilterModeNearest uses nearest-neighbor filtering. FilterModeNearest FilterMode = iota // FilterModeLinear uses linear interpolation. FilterModeLinear )
type ImageCopyTexture ¶
type ImageCopyTexture struct {
// Texture is the texture to copy to/from.
Texture uintptr // TextureID as uintptr for now
// MipLevel is the mip level to copy.
MipLevel uint32
// Origin is the origin of the copy in the texture.
Origin Origin3D
// Aspect is the aspect of the texture to copy.
Aspect TextureAspect
}
ImageCopyTexture describes a texture copy target.
type IndexFormat ¶
type IndexFormat uint8
IndexFormat describes the format of index buffer data.
const ( // IndexFormatUint16 uses 16-bit unsigned integers. IndexFormatUint16 IndexFormat = iota // IndexFormatUint32 uses 32-bit unsigned integers. IndexFormatUint32 )
type InstanceDescriptor ¶
type InstanceDescriptor struct {
// Backends specifies which backends to enable.
Backends Backends
// Flags controls instance behavior.
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 the default instance descriptor.
type InstanceFlags ¶
type InstanceFlags uint8
InstanceFlags controls instance behavior.
const ( // 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 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 layers.
MaxTextureArrayLayers uint32
// MaxBindGroups is the maximum number of bind groups.
MaxBindGroups uint32
// MaxBindGroupsPlusVertexBuffers is the max bind groups + vertex buffers.
MaxBindGroupsPlusVertexBuffers uint32
// MaxBindingsPerBindGroup is the max bindings per bind group.
MaxBindingsPerBindGroup uint32
// MaxDynamicUniformBuffersPerPipelineLayout is the max dynamic uniform buffers.
MaxDynamicUniformBuffersPerPipelineLayout uint32
// MaxDynamicStorageBuffersPerPipelineLayout is the max dynamic storage buffers.
MaxDynamicStorageBuffersPerPipelineLayout uint32
// MaxSampledTexturesPerShaderStage is the max sampled textures per stage.
MaxSampledTexturesPerShaderStage uint32
// MaxSamplersPerShaderStage is the max samplers per stage.
MaxSamplersPerShaderStage uint32
// MaxStorageBuffersPerShaderStage is the max storage buffers per stage.
MaxStorageBuffersPerShaderStage uint32
// MaxStorageTexturesPerShaderStage is the max storage textures per stage.
MaxStorageTexturesPerShaderStage uint32
// MaxUniformBuffersPerShaderStage is the max uniform buffers per stage.
MaxUniformBuffersPerShaderStage uint32
// MaxUniformBufferBindingSize is the max uniform buffer binding size.
MaxUniformBufferBindingSize uint64
// MaxStorageBufferBindingSize is the max storage buffer binding size.
MaxStorageBufferBindingSize uint64
// MinUniformBufferOffsetAlignment is the min uniform buffer offset alignment.
MinUniformBufferOffsetAlignment uint32
// MinStorageBufferOffsetAlignment is the min storage buffer offset alignment.
MinStorageBufferOffsetAlignment uint32
// MaxVertexBuffers is the max vertex buffers.
MaxVertexBuffers uint32
// MaxBufferSize is the max buffer size.
MaxBufferSize uint64
// MaxVertexAttributes is the max vertex attributes.
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.
MaxColorAttachments uint32
// MaxColorAttachmentBytesPerSample is the max bytes per sample for color.
MaxColorAttachmentBytesPerSample uint32
// MaxComputeWorkgroupStorageSize is the max compute workgroup storage.
MaxComputeWorkgroupStorageSize uint32
// MaxComputeInvocationsPerWorkgroup is the max compute invocations per group.
MaxComputeInvocationsPerWorkgroup uint32
// MaxComputeWorkgroupSizeX is the max compute workgroup size X.
MaxComputeWorkgroupSizeX uint32
// MaxComputeWorkgroupSizeY is the max compute workgroup size Y.
MaxComputeWorkgroupSizeY uint32
// MaxComputeWorkgroupSizeZ is the max compute workgroup size Z.
MaxComputeWorkgroupSizeZ uint32
// MaxComputeWorkgroupsPerDimension is the max compute workgroups per dimension.
MaxComputeWorkgroupsPerDimension uint32
// MaxPushConstantSize is the max push constant size.
MaxPushConstantSize uint32
// MaxNonSamplerBindings is the max non-sampler bindings.
MaxNonSamplerBindings uint32
}
Limits describes the GPU resource limits.
func DownlevelLimits ¶
func DownlevelLimits() Limits
DownlevelLimits returns more conservative limits for older hardware.
type MemoryHints ¶
type MemoryHints uint8
MemoryHints provides memory allocation hints.
const ( // MemoryHintsPerformance optimizes for performance. MemoryHintsPerformance MemoryHints = iota // MemoryHintsMemoryUsage optimizes for low memory usage. MemoryHintsMemoryUsage )
type MipmapFilterMode ¶
type MipmapFilterMode uint8
MipmapFilterMode describes mipmap filtering.
const ( // MipmapFilterModeNearest selects the nearest mip level. MipmapFilterModeNearest MipmapFilterMode = iota // MipmapFilterModeLinear interpolates between mip levels. MipmapFilterModeLinear )
type MultisampleState ¶
type MultisampleState struct {
// Count is the number of samples.
Count uint32
// Mask is the sample mask.
Mask uint64
// AlphaToCoverageEnabled enables alpha-to-coverage.
AlphaToCoverageEnabled bool
}
MultisampleState describes multisampling.
func DefaultMultisampleState ¶
func DefaultMultisampleState() MultisampleState
DefaultMultisampleState returns the default multisample state.
type Origin3D ¶
type Origin3D struct {
// X is the X coordinate.
X uint32
// Y is the Y coordinate.
Y uint32
// Z is the Z coordinate.
Z uint32
}
Origin3D describes a 3D origin.
type PipelineLayoutDescriptor ¶
type PipelineLayoutDescriptor struct {
// Label is a debug label.
Label string
// BindGroupLayouts are the bind group layouts.
BindGroupLayouts []BindGroupLayoutHandle
// PushConstantRanges describe push constant ranges.
PushConstantRanges []PushConstantRange
}
PipelineLayoutDescriptor describes a pipeline layout.
type PowerPreference ¶
type PowerPreference uint8
PowerPreference specifies power consumption preference.
const ( // PowerPreferenceNone has no preference. PowerPreferenceNone PowerPreference = iota // PowerPreferenceLowPower prefers low power consumption (integrated GPU). PowerPreferenceLowPower // PowerPreferenceHighPerformance prefers high performance (discrete GPU). PowerPreferenceHighPerformance )
type PrimitiveState ¶
type PrimitiveState struct {
// Topology is the primitive topology.
Topology PrimitiveTopology
// StripIndexFormat is the index format for strip topologies.
StripIndexFormat *IndexFormat
// FrontFace is the front face winding.
FrontFace FrontFace
// CullMode specifies which faces to cull.
CullMode CullMode
// UnclippedDepth enables unclipped depth.
UnclippedDepth bool
}
PrimitiveState describes primitive assembly.
type PrimitiveTopology ¶
type PrimitiveTopology uint8
PrimitiveTopology describes how vertices form primitives.
const ( PrimitiveTopologyPointList PrimitiveTopology = iota PrimitiveTopologyLineList PrimitiveTopologyLineStrip PrimitiveTopologyTriangleList PrimitiveTopologyTriangleStrip )
type ProgrammableStage ¶
type ProgrammableStage struct {
// EntryPoint is the entry point function name.
EntryPoint string
// Constants are pipeline-overridable constants.
Constants map[string]float64
}
ProgrammableStage describes a programmable shader stage.
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.
type RenderPassColorAttachment ¶
type RenderPassColorAttachment struct {
// View is the texture view to render to.
View TextureViewHandle
// ResolveTarget is the texture view for multisample resolve.
ResolveTarget *TextureViewHandle
// LoadOp describes how to load the attachment.
LoadOp LoadOp
// StoreOp describes how to store the attachment.
StoreOp StoreOp
// ClearValue is the clear color.
ClearValue Color
}
RenderPassColorAttachment describes a color attachment.
type RenderPassDepthStencilAttachment ¶
type RenderPassDepthStencilAttachment struct {
// View is the texture view.
View TextureViewHandle
// 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 a debug label.
Label string
// ColorAttachments are the color attachments.
ColorAttachments []RenderPassColorAttachment
// DepthStencilAttachment is the depth-stencil attachment.
DepthStencilAttachment *RenderPassDepthStencilAttachment
// OcclusionQuerySet is the occlusion query set.
OcclusionQuerySet QuerySetHandle
// TimestampWrites describe timestamp queries.
TimestampWrites *RenderPassTimestampWrites
}
RenderPassDescriptor describes a render pass.
type RenderPassTimestampWrites ¶
type RenderPassTimestampWrites struct {
// QuerySet is the query set for timestamps.
QuerySet QuerySetHandle
// BeginningOfPassWriteIndex is the index for start timestamp.
BeginningOfPassWriteIndex *uint32
// EndOfPassWriteIndex is the index for end timestamp.
EndOfPassWriteIndex *uint32
}
RenderPassTimestampWrites describes timestamp writes.
type RequestAdapterOptions ¶
type RequestAdapterOptions struct {
// PowerPreference indicates power consumption preference.
PowerPreference PowerPreference
// ForceFallbackAdapter forces the use of a fallback adapter.
ForceFallbackAdapter bool
// CompatibleSurface is an optional surface the adapter must support.
CompatibleSurface *Surface
}
RequestAdapterOptions controls adapter selection.
type SamplerBinding ¶
type SamplerBinding struct {
// Sampler is the sampler handle.
Sampler SamplerHandle
}
SamplerBinding binds a sampler.
type SamplerBindingLayout ¶
type SamplerBindingLayout struct {
// Type is the sampler binding type.
Type SamplerBindingType
}
SamplerBindingLayout describes a sampler binding.
type SamplerBindingType ¶
type SamplerBindingType uint8
SamplerBindingType describes how a sampler is bound.
const ( // SamplerBindingTypeUndefined is undefined. SamplerBindingTypeUndefined SamplerBindingType = iota // SamplerBindingTypeFiltering supports filtering. SamplerBindingTypeFiltering // SamplerBindingTypeNonFiltering does not filter. SamplerBindingTypeNonFiltering // SamplerBindingTypeComparison is for depth comparison. SamplerBindingTypeComparison )
type SamplerDescriptor ¶
type SamplerDescriptor struct {
// Label is a debug label.
Label string
// AddressModeU is the U coordinate addressing mode.
AddressModeU AddressMode
// AddressModeV is the V coordinate addressing mode.
AddressModeV AddressMode
// AddressModeW is the W coordinate addressing mode.
AddressModeW AddressMode
// MagFilter is the magnification filter.
MagFilter FilterMode
// MinFilter is the minification filter.
MinFilter FilterMode
// MipmapFilter is the mipmap filter.
MipmapFilter MipmapFilterMode
// LodMinClamp is the minimum level of detail.
LodMinClamp float32
// LodMaxClamp is the maximum level of detail.
LodMaxClamp float32
// Compare is the comparison function for depth sampling.
Compare CompareFunction
// MaxAnisotropy is the max anisotropy level (1-16).
MaxAnisotropy uint16
}
SamplerDescriptor describes a sampler.
func DefaultSamplerDescriptor ¶
func DefaultSamplerDescriptor() SamplerDescriptor
DefaultSamplerDescriptor returns the default sampler descriptor.
type ShaderModuleDescriptor ¶
type ShaderModuleDescriptor struct {
// Label is a debug label.
Label string
// Source is the shader source (WGSL, SPIR-V, etc.).
Source ShaderSource
}
ShaderModuleDescriptor describes a shader module.
type ShaderSource ¶
type ShaderSource interface {
// contains filtered or unexported methods
}
ShaderSource represents shader source code.
type ShaderSourceGLSL ¶
type ShaderSourceGLSL struct {
// Code is the GLSL source code.
Code string
// Stage is the shader stage.
Stage ShaderStage
// Defines is a map of preprocessor defines.
Defines map[string]string
}
ShaderSourceGLSL is GLSL shader source.
type ShaderSourceSPIRV ¶
type ShaderSourceSPIRV struct {
// Code is the SPIR-V bytecode.
Code []uint32
}
ShaderSourceSPIRV is SPIR-V shader source.
type ShaderSourceWGSL ¶
type ShaderSourceWGSL struct {
// Code is the WGSL source code.
Code string
}
ShaderSourceWGSL is WGSL shader source.
type ShaderStage ¶
type ShaderStage uint8
ShaderStage represents a shader stage.
const ( // ShaderStageNone represents no shader stage. ShaderStageNone ShaderStage = 0 // ShaderStageVertex is the vertex shader stage. ShaderStageVertex ShaderStage = 1 << iota // ShaderStageFragment is the fragment shader stage. ShaderStageFragment // ShaderStageCompute is the compute shader stage. ShaderStageCompute )
type StorageTextureAccess ¶
type StorageTextureAccess uint8
StorageTextureAccess describes storage texture access mode.
const ( // StorageTextureAccessWriteOnly allows write-only access. StorageTextureAccessWriteOnly StorageTextureAccess = iota // StorageTextureAccessReadOnly allows read-only access. StorageTextureAccessReadOnly // StorageTextureAccessReadWrite allows read-write access. StorageTextureAccessReadWrite )
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 Surface ¶
type Surface struct {
// Handle is platform-specific surface handle.
Handle uintptr
}
Surface represents a window surface (placeholder).
type TextureAspect ¶
type TextureAspect uint8
TextureAspect describes which aspects of a texture to access.
const ( // TextureAspectAll accesses all aspects. TextureAspectAll TextureAspect = iota // TextureAspectStencilOnly accesses only stencil. TextureAspectStencilOnly // TextureAspectDepthOnly accesses only depth. TextureAspectDepthOnly )
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.
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.
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 a debug label.
Label string
// Size is the texture size.
Size Extent3D
// MipLevelCount is the number of mip levels.
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.
ViewFormats []TextureFormat
}
TextureDescriptor describes a texture.
type TextureDimension ¶
type TextureDimension uint8
TextureDimension describes texture dimensions.
const ( // TextureDimension1D is a 1D texture. TextureDimension1D TextureDimension = iota // TextureDimension2D is a 2D texture. TextureDimension2D // TextureDimension3D is a 3D texture. TextureDimension3D )
type TextureFormat ¶
type TextureFormat uint32
TextureFormat describes the format of a texture.
const ( // TextureFormatUndefined is an undefined format. TextureFormatUndefined TextureFormat = iota // 8-bit formats TextureFormatR8Unorm TextureFormatR8Snorm TextureFormatR8Uint TextureFormatR8Sint // 16-bit formats TextureFormatR16Uint TextureFormatR16Sint TextureFormatR16Float TextureFormatRG8Unorm TextureFormatRG8Snorm TextureFormatRG8Uint TextureFormatRG8Sint // 32-bit formats TextureFormatR32Uint TextureFormatR32Sint TextureFormatR32Float TextureFormatRG16Uint TextureFormatRG16Sint TextureFormatRG16Float TextureFormatRGBA8Unorm TextureFormatRGBA8UnormSrgb TextureFormatRGBA8Snorm TextureFormatRGBA8Uint TextureFormatRGBA8Sint TextureFormatBGRA8Unorm TextureFormatBGRA8UnormSrgb // Packed formats TextureFormatRGB9E5Ufloat TextureFormatRGB10A2Uint TextureFormatRGB10A2Unorm TextureFormatRG11B10Ufloat // 64-bit formats TextureFormatRG32Uint TextureFormatRG32Sint TextureFormatRG32Float TextureFormatRGBA16Uint TextureFormatRGBA16Sint TextureFormatRGBA16Float // 128-bit formats TextureFormatRGBA32Uint TextureFormatRGBA32Sint TextureFormatRGBA32Float // Depth/stencil formats TextureFormatStencil8 TextureFormatDepth16Unorm TextureFormatDepth24Plus TextureFormatDepth24PlusStencil8 TextureFormatDepth32Float TextureFormatDepth32FloatStencil8 // BC compressed formats TextureFormatBC1RGBAUnorm TextureFormatBC1RGBAUnormSrgb TextureFormatBC2RGBAUnorm TextureFormatBC2RGBAUnormSrgb TextureFormatBC3RGBAUnorm TextureFormatBC3RGBAUnormSrgb TextureFormatBC4RUnorm TextureFormatBC4RSnorm TextureFormatBC5RGUnorm TextureFormatBC5RGSnorm TextureFormatBC6HRGBUfloat TextureFormatBC6HRGBFloat TextureFormatBC7RGBAUnorm TextureFormatBC7RGBAUnormSrgb // ETC2 compressed formats TextureFormatETC2RGB8Unorm TextureFormatETC2RGB8UnormSrgb TextureFormatETC2RGB8A1Unorm TextureFormatETC2RGB8A1UnormSrgb TextureFormatETC2RGBA8Unorm TextureFormatETC2RGBA8UnormSrgb TextureFormatEACR11Unorm TextureFormatEACR11Snorm TextureFormatEACRG11Unorm TextureFormatEACRG11Snorm // ASTC compressed formats TextureFormatASTC4x4Unorm TextureFormatASTC4x4UnormSrgb TextureFormatASTC5x4Unorm TextureFormatASTC5x4UnormSrgb TextureFormatASTC5x5Unorm TextureFormatASTC5x5UnormSrgb TextureFormatASTC6x5Unorm TextureFormatASTC6x5UnormSrgb TextureFormatASTC6x6Unorm TextureFormatASTC6x6UnormSrgb TextureFormatASTC8x5Unorm TextureFormatASTC8x5UnormSrgb TextureFormatASTC8x6Unorm TextureFormatASTC8x6UnormSrgb TextureFormatASTC8x8Unorm TextureFormatASTC8x8UnormSrgb TextureFormatASTC10x5Unorm TextureFormatASTC10x5UnormSrgb TextureFormatASTC10x6Unorm TextureFormatASTC10x6UnormSrgb TextureFormatASTC10x8Unorm TextureFormatASTC10x8UnormSrgb TextureFormatASTC10x10Unorm TextureFormatASTC10x10UnormSrgb TextureFormatASTC12x10Unorm TextureFormatASTC12x10UnormSrgb TextureFormatASTC12x12Unorm TextureFormatASTC12x12UnormSrgb )
type TextureSampleType ¶
type TextureSampleType uint8
TextureSampleType describes the sample type of a texture.
const ( // TextureSampleTypeFloat samples as floating-point. TextureSampleTypeFloat TextureSampleType = iota // TextureSampleTypeUnfilterableFloat samples as unfilterable float. TextureSampleTypeUnfilterableFloat // TextureSampleTypeDepth samples as depth. TextureSampleTypeDepth // TextureSampleTypeSint samples as signed integer. TextureSampleTypeSint // TextureSampleTypeUint samples as unsigned integer. TextureSampleTypeUint )
type TextureUsage ¶
type TextureUsage uint32
TextureUsage describes how a texture can be used.
const ( // TextureUsageCopySrc allows the texture to be a copy source. TextureUsageCopySrc TextureUsage = 1 << iota // TextureUsageCopyDst allows the texture to be a copy destination. TextureUsageCopyDst // TextureUsageTextureBinding allows texture binding in shaders. TextureUsageTextureBinding // TextureUsageStorageBinding allows storage binding in shaders. TextureUsageStorageBinding // TextureUsageRenderAttachment allows use as a render attachment. TextureUsageRenderAttachment )
type TextureViewBinding ¶
type TextureViewBinding struct {
// TextureView is the texture view handle.
TextureView TextureViewHandle
}
TextureViewBinding binds a texture view.
type TextureViewDescriptor ¶
type TextureViewDescriptor struct {
// Label is a debug label.
Label string
// Format is the view format (defaults to texture format).
Format TextureFormat
// Dimension is the view dimension.
Dimension TextureViewDimension
// Aspect specifies which aspect to view.
Aspect TextureAspect
// BaseMipLevel is the first mip level accessible.
BaseMipLevel uint32
// MipLevelCount is the number of accessible mip levels.
MipLevelCount uint32
// BaseArrayLayer is the first array layer accessible.
BaseArrayLayer uint32
// ArrayLayerCount is the number of accessible array layers.
ArrayLayerCount uint32
}
TextureViewDescriptor describes a texture view.
type TextureViewDimension ¶
type TextureViewDimension uint8
TextureViewDimension describes a texture view dimension.
const ( // TextureViewDimensionUndefined uses the same dimension as the texture. TextureViewDimensionUndefined TextureViewDimension = iota // TextureViewDimension1D is a 1D texture view. TextureViewDimension1D // TextureViewDimension2D is a 2D texture view. TextureViewDimension2D // TextureViewDimension2DArray is a 2D array texture view. TextureViewDimension2DArray // TextureViewDimensionCube is a cube texture view. TextureViewDimensionCube // TextureViewDimensionCubeArray is a cube array texture view. TextureViewDimensionCubeArray // TextureViewDimension3D is a 3D texture view. TextureViewDimension3D )
type VertexAttribute ¶
type VertexAttribute struct {
// Format is the attribute format.
Format VertexFormat
// Offset is the byte offset within the vertex buffer.
Offset uint64
// ShaderLocation is the location in the shader.
ShaderLocation uint32
}
VertexAttribute describes a vertex attribute.
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 a vertex buffer layout.
type VertexFormat ¶
type VertexFormat uint8
VertexFormat describes a vertex attribute format.
const ( VertexFormatUint8x2 VertexFormat = iota VertexFormatUint8x4 VertexFormatSint8x2 VertexFormatSint8x4 VertexFormatUnorm8x2 VertexFormatUnorm8x4 VertexFormatSnorm8x2 VertexFormatSnorm8x4 VertexFormatUint16x2 VertexFormatUint16x4 VertexFormatSint16x2 VertexFormatSint16x4 VertexFormatUnorm16x2 VertexFormatUnorm16x4 VertexFormatSnorm16x2 VertexFormatSnorm16x4 VertexFormatFloat16x2 VertexFormatFloat16x4 VertexFormatFloat32 VertexFormatFloat32x2 VertexFormatFloat32x3 VertexFormatFloat32x4 VertexFormatUint32 VertexFormatUint32x2 VertexFormatUint32x3 VertexFormatUint32x4 VertexFormatSint32 VertexFormatSint32x2 VertexFormatSint32x3 VertexFormatSint32x4 VertexFormatUnorm1010102 )
func (VertexFormat) Size ¶
func (f VertexFormat) Size() uint64
Size returns the byte size of the vertex format.
type VertexState ¶
type VertexState struct {
// Buffers are the vertex buffer layouts.
Buffers []VertexBufferLayout
}
VertexState describes the vertex stage of a render pipeline.
type VertexStepMode ¶
type VertexStepMode uint8
VertexStepMode describes how vertex data is stepped.
const ( // VertexStepModeVertex steps per vertex. VertexStepModeVertex VertexStepMode = iota // VertexStepModeInstance steps per instance. VertexStepModeInstance )