Documentation
¶
Overview ¶
Package wgpu is a minimal, compute-only CGO binding over wgpu-native v29.0.0.0.
It exists to give goinfer's ./gpu package a drop-in replacement for the slice of github.com/cogentcore/webgpu it uses, with full control over the WGSL dot4I8Packed builtin and the wgpu-native version. The exported type, method, and descriptor names mirror cogentcore/webgpu so migrating goinfer is a near-mechanical import swap (s,github.com/cogentcore/webgpu/wgpu,github.com/townsendmerino/wgpu,).
Why CGO and not the zero-CGO goffi path (go-webgpu): goffi targets a fixed Go runtime crosscall2 callback ABI (Go 1.25) and SIGABRTs at RequestAdapter on Go 1.26. cgo callbacks are robust across Go versions.
v29's webgpu.h is fully async (WGPUFuture + WGPUCallbackInfo for RequestAdapter / RequestDevice / MapAsync). This package hides that behind synchronous wrappers: adapter/device requests are driven to completion in C (wgpuInstanceProcessEvents) and buffer maps complete during Device.Poll, so the surface matches cogentcore's blocking style.
Beyond the cogentcore drop-in subset this package also exposes v29-only capabilities useful for the dot4I8Packed work: GPU timestamp queries (for honest on-device DP4A measurement), pipeline-overridable WGSL constants, push-constant-equivalent "immediates", and subgroup adapter info.
All struct layouts are transcribed from the webgpu.h / wgpu.h that ship inside the v29.0.0.0 release archives (vendored under lib/), which match the linked libwgpu_native.a. A wrong field offset is silent memory corruption, not a compile error — see the probe in cmd/dot4probe for cross-checking.
Index ¶
- Constants
- func FromBytes[E any](src []byte) []E
- func GetVersion() uint32
- func SetLogLevel(level LogLevel)
- func ToBytes[E any](src []E) []byte
- type Adapter
- type AdapterInfo
- type AdapterType
- type BackendType
- type BindGroup
- type BindGroupDescriptor
- type BindGroupEntry
- type BindGroupLayout
- type BindGroupLayoutDescriptor
- type BindGroupLayoutEntry
- type Buffer
- func (p *Buffer) Destroy()
- func (p *Buffer) GetMappedRange(offset, size uint) []byte
- func (p *Buffer) GetSize() uint64
- func (p *Buffer) GetUsage() BufferUsage
- func (p *Buffer) MapAsync(mode MapMode, offset uint64, size uint64, callback BufferMapCallback) error
- func (p *Buffer) Release()
- func (p *Buffer) Unmap() error
- type BufferBindingLayout
- type BufferBindingType
- type BufferDescriptor
- type BufferInitDescriptor
- type BufferMapAsyncStatus
- type BufferMapCallback
- type BufferUsage
- type CommandBuffer
- type CommandBufferDescriptor
- type CommandEncoder
- func (p *CommandEncoder) BeginComputePass(descriptor *ComputePassDescriptor) *ComputePassEncoder
- func (p *CommandEncoder) CopyBufferToBuffer(source *Buffer, sourceOffset uint64, destination *Buffer, ...) error
- func (p *CommandEncoder) Finish(descriptor *CommandBufferDescriptor) (*CommandBuffer, error)
- func (p *CommandEncoder) Release()
- func (p *CommandEncoder) ResolveQuerySet(querySet *QuerySet, firstQuery, queryCount uint32, destination *Buffer, ...)
- type CommandEncoderDescriptor
- type ComputePassDescriptor
- type ComputePassEncoder
- func (p *ComputePassEncoder) DispatchWorkgroups(workgroupCountX, workgroupCountY, workgroupCountZ uint32)
- func (p *ComputePassEncoder) End() error
- func (p *ComputePassEncoder) RecordSteps(steps []ComputeStep)
- func (p *ComputePassEncoder) Release()
- func (p *ComputePassEncoder) SetBindGroup(groupIndex uint32, group *BindGroup, dynamicOffsets []uint32)
- func (p *ComputePassEncoder) SetImmediates(offset uint32, data []byte)
- func (p *ComputePassEncoder) SetPipeline(pipeline *ComputePipeline)
- type ComputePassTimestampWrites
- type ComputePipeline
- type ComputePipelineDescriptor
- type ComputeStep
- type ConstantEntry
- type Device
- func (d *Device) CreateBindGroup(descriptor *BindGroupDescriptor) (*BindGroup, error)
- func (d *Device) CreateBindGroupLayout(descriptor *BindGroupLayoutDescriptor) (*BindGroupLayout, error)
- func (d *Device) CreateBuffer(descriptor *BufferDescriptor) (*Buffer, error)
- func (d *Device) CreateBufferInit(descriptor *BufferInitDescriptor) (*Buffer, error)
- func (d *Device) CreateCommandEncoder(descriptor *CommandEncoderDescriptor) (*CommandEncoder, error)
- func (d *Device) CreateComputePipeline(descriptor *ComputePipelineDescriptor) (*ComputePipeline, error)
- func (d *Device) CreateQuerySet(descriptor *QuerySetDescriptor) (*QuerySet, error)
- func (d *Device) CreateShaderModule(descriptor *ShaderModuleDescriptor) (*ShaderModule, error)
- func (d *Device) GetLimits() SupportedLimits
- func (d *Device) GetQueue() *Queue
- func (d *Device) HasFeature(feature FeatureName) bool
- func (d *Device) Poll(wait bool, wrappedSubmissionIndex *WrappedSubmissionIndex) bool
- func (d *Device) Release()
- type DeviceDescriptor
- type DeviceLostCallback
- type ErrorType
- type FeatureName
- type Instance
- type InstanceDescriptor
- type Limits
- type LogLevel
- type MapMode
- type NativeFeature
- type PipelineLayout
- type PowerPreference
- type ProgrammableStageDescriptor
- type QuerySet
- type QuerySetDescriptor
- type QueryType
- type Queue
- type RequestAdapterOptions
- type RequiredLimits
- type ShaderModule
- type ShaderModuleDescriptor
- type ShaderModuleWGSLDescriptor
- type ShaderStage
- type SubmissionIndex
- type SupportedLimits
- type WrappedSubmissionIndex
Constants ¶
const ( // LimitU32Undefined / LimitU64Undefined are the "no requirement / use // default" sentinels for limit fields (UINT32_MAX / UINT64_MAX in v29). LimitU32Undefined uint32 = 0xffffffff LimitU64Undefined uint64 = 0xffffffffffffffff )
const QuerySetIndexUndefined uint32 = 0xffffffff
QuerySetIndexUndefined marks a timestamp write endpoint as unused.
Variables ¶
This section is empty.
Functions ¶
func FromBytes ¶
FromBytes reinterprets a byte slice as a slice of E (no copy). Mirrors cogentcore/webgpu's helper of the same name. Panics if len is not a multiple of the element size.
func GetVersion ¶
func GetVersion() uint32
GetVersion returns the linked wgpu-native version as a packed integer.
func SetLogLevel ¶
func SetLogLevel(level LogLevel)
SetLogLevel controls wgpu-native's internal log verbosity (default: silent).
Types ¶
type Adapter ¶
type Adapter struct {
// contains filtered or unexported fields
}
Adapter mirrors cogentcore/webgpu.Adapter.
func (*Adapter) EnumerateFeatures ¶
func (p *Adapter) EnumerateFeatures() []FeatureName
EnumerateFeatures returns the features the adapter supports (standard + native; native features share the WGPUFeatureName value space).
func (*Adapter) GetInfo ¶
func (p *Adapter) GetInfo() AdapterInfo
GetInfo returns identifying information about the adapter.
func (*Adapter) GetLimits ¶
func (p *Adapter) GetLimits() SupportedLimits
GetLimits returns the adapter's supported limits.
func (*Adapter) HasFeature ¶
func (p *Adapter) HasFeature(feature FeatureName) bool
HasFeature reports whether the adapter supports a feature.
func (*Adapter) RequestDevice ¶
func (p *Adapter) RequestDevice(descriptor *DeviceDescriptor) (*Device, error)
RequestDevice synchronously requests a device. An uncaptured-error callback is installed so validation failures surface as real messages (and to stderr).
type AdapterInfo ¶
type AdapterInfo struct {
VendorId uint32
VendorName string
Architecture string
DeviceId uint32
Name string
DriverDescription string
AdapterType AdapterType
BackendType BackendType
SubgroupMinSize uint32 // v29
SubgroupMaxSize uint32 // v29
}
AdapterInfo mirrors cogentcore's AdapterInfo, plus v29 subgroup sizes.
type AdapterType ¶
type AdapterType uint32
AdapterType mirrors WGPUAdapterType.
const ( AdapterTypeDiscreteGPU AdapterType = C.WGPUAdapterType_DiscreteGPU AdapterTypeIntegratedGPU AdapterType = C.WGPUAdapterType_IntegratedGPU AdapterTypeCPU AdapterType = C.WGPUAdapterType_CPU AdapterTypeUnknown AdapterType = C.WGPUAdapterType_Unknown )
func (AdapterType) String ¶
func (t AdapterType) String() string
type BackendType ¶
type BackendType uint32
BackendType mirrors WGPUBackendType.
const ( BackendTypeUndefined BackendType = C.WGPUBackendType_Undefined BackendTypeNull BackendType = C.WGPUBackendType_Null BackendTypeWebGPU BackendType = C.WGPUBackendType_WebGPU BackendTypeD3D11 BackendType = C.WGPUBackendType_D3D11 BackendTypeD3D12 BackendType = C.WGPUBackendType_D3D12 BackendTypeMetal BackendType = C.WGPUBackendType_Metal BackendTypeVulkan BackendType = C.WGPUBackendType_Vulkan BackendTypeOpenGL BackendType = C.WGPUBackendType_OpenGL BackendTypeOpenGLES BackendType = C.WGPUBackendType_OpenGLES )
func (BackendType) String ¶
func (t BackendType) String() string
type BindGroupDescriptor ¶
type BindGroupDescriptor struct {
Label string
Layout *BindGroupLayout
Entries []BindGroupEntry
}
BindGroupDescriptor mirrors cogentcore.
type BindGroupEntry ¶
type BindGroupEntry struct {
Binding uint32
Buffer *Buffer
Offset uint64
Size uint64
Sampler *struct{} // unused (source compat)
TextureView *struct{} // unused (source compat)
}
BindGroupEntry mirrors cogentcore. Only buffer bindings are used by the compute-only consumer; Sampler/TextureView are accepted for source compatibility but unused.
type BindGroupLayout ¶
type BindGroupLayout struct {
// contains filtered or unexported fields
}
func (*BindGroupLayout) Release ¶
func (p *BindGroupLayout) Release()
type BindGroupLayoutDescriptor ¶
type BindGroupLayoutDescriptor struct {
Label string
Entries []BindGroupLayoutEntry
}
BindGroupLayoutDescriptor mirrors cogentcore's subset.
type BindGroupLayoutEntry ¶
type BindGroupLayoutEntry struct {
Binding uint32
Visibility ShaderStage
Buffer BufferBindingLayout
}
BindGroupLayoutEntry mirrors cogentcore's subset (buffer bindings, compute visibility).
type Buffer ¶
type Buffer struct {
// contains filtered or unexported fields
}
Buffer mirrors cogentcore/webgpu.Buffer.
func (*Buffer) GetMappedRange ¶
GetMappedRange returns a Go slice aliasing the buffer's mapped CPU range. Valid only while the buffer is mapped.
func (*Buffer) GetUsage ¶
func (p *Buffer) GetUsage() BufferUsage
GetUsage returns the buffer's usage flags.
type BufferBindingLayout ¶
type BufferBindingLayout struct {
Type BufferBindingType
HasDynamicOffset bool
MinBindingSize uint64
}
BufferBindingLayout mirrors cogentcore's subset.
type BufferBindingType ¶
type BufferBindingType uint32
BufferBindingType mirrors WGPUBufferBindingType.
const ( BufferBindingTypeUniform BufferBindingType = C.WGPUBufferBindingType_Uniform BufferBindingTypeStorage BufferBindingType = C.WGPUBufferBindingType_Storage BufferBindingTypeReadOnlyStorage BufferBindingType = C.WGPUBufferBindingType_ReadOnlyStorage )
type BufferDescriptor ¶
type BufferDescriptor struct {
Label string
Usage BufferUsage
Size uint64
MappedAtCreation bool
}
BufferDescriptor mirrors cogentcore.
type BufferInitDescriptor ¶
type BufferInitDescriptor struct {
Label string
Contents []byte
Usage BufferUsage
}
BufferInitDescriptor mirrors cogentcore: a buffer created with initial contents (uploaded via mappedAtCreation).
type BufferMapAsyncStatus ¶
type BufferMapAsyncStatus uint32
BufferMapAsyncStatus mirrors the relevant WGPUMapAsyncStatus values. The names match cogentcore/webgpu for drop-in compatibility. Unknown (0) is the zero value (the in-flight sentinel callers initialise to).
const ( BufferMapAsyncStatusUnknown BufferMapAsyncStatus = 0 BufferMapAsyncStatusSuccess BufferMapAsyncStatus = C.WGPUMapAsyncStatus_Success BufferMapAsyncStatusCallbackCancelled BufferMapAsyncStatus = C.WGPUMapAsyncStatus_CallbackCancelled BufferMapAsyncStatusError BufferMapAsyncStatus = C.WGPUMapAsyncStatus_Error BufferMapAsyncStatusAborted BufferMapAsyncStatus = C.WGPUMapAsyncStatus_Aborted )
func (BufferMapAsyncStatus) String ¶
func (s BufferMapAsyncStatus) String() string
type BufferMapCallback ¶
type BufferMapCallback func(status BufferMapAsyncStatus)
BufferMapCallback is invoked when an async buffer map completes.
type BufferUsage ¶
type BufferUsage uint64
BufferUsage is a bitset of WGPUBufferUsage flags (64-bit in v29).
const ( BufferUsageNone BufferUsage = 0x0000000000000000 BufferUsageMapRead BufferUsage = 0x0000000000000001 BufferUsageCopySrc BufferUsage = 0x0000000000000004 BufferUsageCopyDst BufferUsage = 0x0000000000000008 BufferUsageUniform BufferUsage = 0x0000000000000040 BufferUsageStorage BufferUsage = 0x0000000000000080 // QueryResolve is needed for the destination of ResolveQuerySet (timestamps). BufferUsageQueryResolve BufferUsage = 0x0000000000000200 )
type CommandBuffer ¶
type CommandBuffer struct {
// contains filtered or unexported fields
}
func (*CommandBuffer) Release ¶
func (p *CommandBuffer) Release()
type CommandBufferDescriptor ¶
type CommandBufferDescriptor struct {
Label string
}
CommandBufferDescriptor is optional (label only).
type CommandEncoder ¶
type CommandEncoder struct {
// contains filtered or unexported fields
}
CommandEncoder mirrors cogentcore/webgpu.CommandEncoder.
func (*CommandEncoder) BeginComputePass ¶
func (p *CommandEncoder) BeginComputePass(descriptor *ComputePassDescriptor) *ComputePassEncoder
BeginComputePass begins a compute pass. descriptor may be nil.
func (*CommandEncoder) CopyBufferToBuffer ¶
func (p *CommandEncoder) CopyBufferToBuffer(source *Buffer, sourceOffset uint64, destination *Buffer, destinationOffset uint64, size uint64) error
CopyBufferToBuffer records a buffer-to-buffer copy.
func (*CommandEncoder) Finish ¶
func (p *CommandEncoder) Finish(descriptor *CommandBufferDescriptor) (*CommandBuffer, error)
Finish finalizes the encoder into a command buffer. descriptor may be nil.
func (*CommandEncoder) Release ¶
func (p *CommandEncoder) Release()
func (*CommandEncoder) ResolveQuerySet ¶
func (p *CommandEncoder) ResolveQuerySet(querySet *QuerySet, firstQuery, queryCount uint32, destination *Buffer, destinationOffset uint64)
ResolveQuerySet copies query results into a buffer (v29 extra; for reading back timestamps). destination must include BufferUsageQueryResolve.
type CommandEncoderDescriptor ¶
type CommandEncoderDescriptor struct {
Label string
}
CommandEncoderDescriptor is optional (label only).
type ComputePassDescriptor ¶
type ComputePassDescriptor struct {
Label string
TimestampWrites *ComputePassTimestampWrites
}
ComputePassDescriptor mirrors cogentcore, plus optional TimestampWrites.
type ComputePassEncoder ¶
type ComputePassEncoder struct {
// contains filtered or unexported fields
}
ComputePassEncoder mirrors cogentcore/webgpu.ComputePassEncoder.
func (*ComputePassEncoder) DispatchWorkgroups ¶
func (p *ComputePassEncoder) DispatchWorkgroups(workgroupCountX, workgroupCountY, workgroupCountZ uint32)
DispatchWorkgroups dispatches a compute grid.
func (*ComputePassEncoder) End ¶
func (p *ComputePassEncoder) End() error
End ends the compute pass.
func (*ComputePassEncoder) RecordSteps ¶
func (p *ComputePassEncoder) RecordSteps(steps []ComputeStep)
RecordSteps records a batch of dispatches into the pass in a SINGLE cgo crossing — the per-step SetPipeline/SetBindGroup/DispatchWorkgroups loop runs in C. This is an additive, non-cogentcore-mirroring fast path for hot recorders (e.g. a ~hundreds-of-dispatch decode chain): equivalent to calling the three per-call methods for each step in order, but collapses ~3*len(steps) Go->C crossings into one. Consecutive steps that share a pipeline skip the redundant SetPipeline. A nil Pipeline or BindGroup in any step panics (programmer error).
func (*ComputePassEncoder) Release ¶
func (p *ComputePassEncoder) Release()
func (*ComputePassEncoder) SetBindGroup ¶
func (p *ComputePassEncoder) SetBindGroup(groupIndex uint32, group *BindGroup, dynamicOffsets []uint32)
SetBindGroup binds a bind group. dynamicOffsets may be nil.
func (*ComputePassEncoder) SetImmediates ¶
func (p *ComputePassEncoder) SetImmediates(offset uint32, data []byte)
SetImmediates writes push-constant-equivalent "immediate" data (v29 extra; requires NativeFeatureImmediates and a non-zero maxImmediateSize limit).
func (*ComputePassEncoder) SetPipeline ¶
func (p *ComputePassEncoder) SetPipeline(pipeline *ComputePipeline)
SetPipeline binds the compute pipeline.
type ComputePassTimestampWrites ¶
type ComputePassTimestampWrites struct {
QuerySet *QuerySet
BeginningOfPassWriteIndex uint32
EndOfPassWriteIndex uint32
}
ComputePassTimestampWrites attaches timestamp queries to a compute pass (v29 extra). Use QuerySetIndexUndefined to skip an endpoint.
type ComputePipeline ¶
type ComputePipeline struct {
// contains filtered or unexported fields
}
ComputePipeline mirrors cogentcore/webgpu.ComputePipeline.
func (*ComputePipeline) GetBindGroupLayout ¶
func (p *ComputePipeline) GetBindGroupLayout(groupIndex uint32) *BindGroupLayout
GetBindGroupLayout returns the auto-generated bind group layout for a group.
func (*ComputePipeline) Release ¶
func (p *ComputePipeline) Release()
type ComputePipelineDescriptor ¶
type ComputePipelineDescriptor struct {
Label string
Layout *PipelineLayout
Compute ProgrammableStageDescriptor
}
ComputePipelineDescriptor mirrors cogentcore. Layout nil ⇒ auto layout.
type ComputeStep ¶
type ComputeStep struct {
Pipeline *ComputePipeline
BindGroup *BindGroup
X, Y, Z uint32
}
ComputeStep is one dispatch in a RecordSteps batch: bind Pipeline + BindGroup at group 0 (no dynamic offsets) and dispatch (X,Y,Z) workgroups. It models the common serial-decode-spine step (one bind group at group 0); use the per-call SetPipeline/SetBindGroup/DispatchWorkgroups methods directly if you need a non-zero group index or dynamic offsets.
type ConstantEntry ¶
ConstantEntry sets a WGSL pipeline-overridable constant (v29 extra).
type Device ¶
type Device struct {
// contains filtered or unexported fields
}
Device mirrors cogentcore/webgpu.Device.
func (*Device) CreateBindGroup ¶
func (d *Device) CreateBindGroup(descriptor *BindGroupDescriptor) (*BindGroup, error)
CreateBindGroup creates a bind group.
func (*Device) CreateBindGroupLayout ¶
func (d *Device) CreateBindGroupLayout(descriptor *BindGroupLayoutDescriptor) (*BindGroupLayout, error)
CreateBindGroupLayout creates an explicit bind group layout (buffer bindings).
func (*Device) CreateBuffer ¶
func (d *Device) CreateBuffer(descriptor *BufferDescriptor) (*Buffer, error)
CreateBuffer creates an empty buffer.
func (*Device) CreateBufferInit ¶
func (d *Device) CreateBufferInit(descriptor *BufferInitDescriptor) (*Buffer, error)
CreateBufferInit creates a buffer initialised with Contents. The size is rounded up to a multiple of 4 (COPY/map alignment). Empty contents yields a zero-size buffer error to match practical usage.
func (*Device) CreateCommandEncoder ¶
func (d *Device) CreateCommandEncoder(descriptor *CommandEncoderDescriptor) (*CommandEncoder, error)
CreateCommandEncoder creates a command encoder. descriptor may be nil.
func (*Device) CreateComputePipeline ¶
func (d *Device) CreateComputePipeline(descriptor *ComputePipelineDescriptor) (*ComputePipeline, error)
CreateComputePipeline creates a compute pipeline.
func (*Device) CreateQuerySet ¶
func (d *Device) CreateQuerySet(descriptor *QuerySetDescriptor) (*QuerySet, error)
CreateQuerySet creates a query set (e.g. for timestamp queries).
func (*Device) CreateShaderModule ¶
func (d *Device) CreateShaderModule(descriptor *ShaderModuleDescriptor) (*ShaderModule, error)
CreateShaderModule compiles a WGSL shader module.
func (*Device) GetLimits ¶
func (d *Device) GetLimits() SupportedLimits
GetLimits returns the device's limits.
func (*Device) HasFeature ¶
func (d *Device) HasFeature(feature FeatureName) bool
HasFeature reports whether the device has a feature enabled.
func (*Device) Poll ¶
func (d *Device) Poll(wait bool, wrappedSubmissionIndex *WrappedSubmissionIndex) bool
Poll processes pending work. With wait=true it blocks until the queue is empty (or, if wrappedSubmissionIndex is non-nil, until that submission completes), firing any pending buffer-map callbacks. Returns whether the queue is now empty.
type DeviceDescriptor ¶
type DeviceDescriptor struct {
Label string
RequiredFeatures []FeatureName
RequiredLimits *RequiredLimits
DeviceLostCallback DeviceLostCallback // accepted but not wired
TracePath string // accepted but not wired
}
DeviceDescriptor mirrors cogentcore's subset.
type DeviceLostCallback ¶
DeviceLostCallback is retained for source compatibility; it is not wired in the compute-only binding.
type ErrorType ¶
type ErrorType uint32
ErrorType mirrors WGPUErrorType.
const ( ErrorTypeNoError ErrorType = C.WGPUErrorType_NoError ErrorTypeValidation ErrorType = C.WGPUErrorType_Validation ErrorTypeOutOfMemory ErrorType = C.WGPUErrorType_OutOfMemory ErrorTypeInternal ErrorType = C.WGPUErrorType_Internal ErrorTypeUnknown ErrorType = C.WGPUErrorType_Unknown )
type FeatureName ¶
type FeatureName uint32
FeatureName mirrors WGPUFeatureName (standard webgpu features).
const ( FeatureNameTimestampQuery FeatureName = C.WGPUFeatureName_TimestampQuery FeatureNameShaderF16 FeatureName = C.WGPUFeatureName_ShaderF16 FeatureNameFloat32Filterable FeatureName = C.WGPUFeatureName_Float32Filterable FeatureNameSubgroups FeatureName = C.WGPUFeatureName_Subgroups )
type Instance ¶
type Instance struct {
// contains filtered or unexported fields
}
Instance is the entry point. Mirrors cogentcore/webgpu.Instance.
func CreateInstance ¶
func CreateInstance(descriptor *InstanceDescriptor) *Instance
CreateInstance creates a wgpu instance. descriptor may be nil (the common compute case), which uses wgpu-native defaults (all backends).
func (*Instance) RequestAdapter ¶
func (p *Instance) RequestAdapter(options *RequestAdapterOptions) (*Adapter, error)
RequestAdapter synchronously requests an adapter. v29's async future is driven to completion internally, matching cogentcore's blocking signature.
type InstanceDescriptor ¶
type InstanceDescriptor struct {
// Backends is a bitset of WGPUInstanceBackend flags (0 = all).
Backends uint64
}
InstanceDescriptor is an optional descriptor for CreateInstance. For compute-only use, pass nil to CreateInstance.
type Limits ¶
type Limits struct {
MaxTextureDimension1D uint32
MaxTextureDimension2D uint32
MaxTextureDimension3D uint32
MaxTextureArrayLayers uint32
MaxBindGroups uint32
MaxBindGroupsPlusVertexBuffers uint32 // v29
MaxBindingsPerBindGroup uint32
MaxDynamicUniformBuffersPerPipelineLayout uint32
MaxDynamicStorageBuffersPerPipelineLayout uint32
MaxSampledTexturesPerShaderStage uint32
MaxSamplersPerShaderStage uint32
MaxStorageBuffersPerShaderStage uint32
MaxStorageTexturesPerShaderStage uint32
MaxUniformBuffersPerShaderStage uint32
MaxUniformBufferBindingSize uint64
MaxStorageBufferBindingSize uint64
MinUniformBufferOffsetAlignment uint32
MinStorageBufferOffsetAlignment uint32
MaxVertexBuffers uint32
MaxBufferSize uint64
MaxVertexAttributes uint32
MaxVertexBufferArrayStride uint32
MaxInterStageShaderComponents uint32 // deprecated/removed in v29 (ignored)
MaxInterStageShaderVariables uint32
MaxColorAttachments uint32
MaxColorAttachmentBytesPerSample uint32
MaxComputeWorkgroupStorageSize uint32
MaxComputeInvocationsPerWorkgroup uint32
MaxComputeWorkgroupSizeX uint32
MaxComputeWorkgroupSizeY uint32
MaxComputeWorkgroupSizeZ uint32
MaxComputeWorkgroupsPerDimension uint32
// MaxPushConstantSize maps to v29's core WGPULimits.maxImmediateSize
// (push constants became "immediates" in v29).
MaxPushConstantSize uint32
}
Limits mirrors cogentcore/webgpu's Limits (field names preserved for drop-in source compatibility) with v29 additions. MaxInterStageShaderComponents is retained for source compatibility but no longer exists in v29 and is ignored when building C limits. MaxPushConstantSize maps to v29's maxImmediateSize.
func DefaultLimits ¶
func DefaultLimits() Limits
DefaultLimits returns a limit set that is entirely "undefined" — i.e. imposes no requirements, so RequestDevice gets the adapter's defaults. Matches cogentcore: notably MaxBufferSize stays at the u64 sentinel until explicitly set, so a `<` guard never silently keeps a low default.
type LogLevel ¶
type LogLevel uint32
LogLevel mirrors WGPULogLevel.
const ( LogLevelOff LogLevel = C.WGPULogLevel_Off LogLevelError LogLevel = C.WGPULogLevel_Error LogLevelWarn LogLevel = C.WGPULogLevel_Warn LogLevelInfo LogLevel = C.WGPULogLevel_Info LogLevelDebug LogLevel = C.WGPULogLevel_Debug LogLevelTrace LogLevel = C.WGPULogLevel_Trace )
type NativeFeature ¶
type NativeFeature uint32
NativeFeature mirrors wgpu-native's WGPUNativeFeature extension enum. These sit in the same WGPUFeatureName value space (0x0003xxxx) and can be passed in DeviceDescriptor.RequiredFeatures and queried via HasFeature.
const ( NativeFeatureImmediates NativeFeature = C.WGPUNativeFeature_Immediates NativeFeaturePipelineStatisticsQuery NativeFeature = C.WGPUNativeFeature_PipelineStatisticsQuery NativeFeatureSubgroup NativeFeature = C.WGPUNativeFeature_Subgroup NativeFeatureSubgroupBarrier NativeFeature = C.WGPUNativeFeature_SubgroupBarrier NativeFeatureTimestampQueryInsidePasses NativeFeature = C.WGPUNativeFeature_TimestampQueryInsidePasses NativeFeatureShaderInt64 NativeFeature = C.WGPUNativeFeature_ShaderInt64 )
func (NativeFeature) AsFeatureName ¶
func (f NativeFeature) AsFeatureName() FeatureName
AsFeatureName lets a NativeFeature be used wherever a FeatureName is expected.
type PipelineLayout ¶
type PipelineLayout struct {
// contains filtered or unexported fields
}
func (*PipelineLayout) Release ¶
func (p *PipelineLayout) Release()
type PowerPreference ¶
type PowerPreference uint32
PowerPreference mirrors WGPUPowerPreference.
const ( PowerPreferenceUndefined PowerPreference = C.WGPUPowerPreference_Undefined PowerPreferenceLowPower PowerPreference = C.WGPUPowerPreference_LowPower PowerPreferenceHighPerformance PowerPreference = C.WGPUPowerPreference_HighPerformance )
type ProgrammableStageDescriptor ¶
type ProgrammableStageDescriptor struct {
Module *ShaderModule
EntryPoint string
Constants []ConstantEntry
}
ProgrammableStageDescriptor mirrors cogentcore, plus optional override Constants (v29 extra) for tuning without editing shader source.
type QuerySet ¶
type QuerySet struct {
// contains filtered or unexported fields
}
type QuerySetDescriptor ¶
QuerySetDescriptor describes a query set (v29 extra, for timestamps).
type QueryType ¶
type QueryType uint32
QueryType mirrors WGPUQueryType.
const ( QueryTypeOcclusion QueryType = C.WGPUQueryType_Occlusion QueryTypeTimestamp QueryType = C.WGPUQueryType_Timestamp )
type Queue ¶
type Queue struct {
// contains filtered or unexported fields
}
Queue mirrors cogentcore/webgpu.Queue.
func (*Queue) GetTimestampPeriod ¶
GetTimestampPeriod returns the number of nanoseconds per timestamp tick (v29 extra; multiply resolved timestamp deltas by this to get nanoseconds).
func (*Queue) Submit ¶
func (p *Queue) Submit(commands ...*CommandBuffer) SubmissionIndex
Submit submits command buffers and returns the submission index (usable with Device.Poll for fenced waits).
type RequestAdapterOptions ¶
type RequestAdapterOptions struct {
PowerPreference PowerPreference
ForceFallbackAdapter bool
BackendType BackendType
// CompatibleSurface is unused in the compute-only binding (kept for source
// compatibility); always nil.
CompatibleSurface *struct{}
}
RequestAdapterOptions mirrors cogentcore's subset.
type RequiredLimits ¶
type RequiredLimits struct{ Limits Limits }
type ShaderModule ¶
type ShaderModule struct {
// contains filtered or unexported fields
}
func (*ShaderModule) Release ¶
func (p *ShaderModule) Release()
type ShaderModuleDescriptor ¶
type ShaderModuleDescriptor struct {
Label string
WGSLDescriptor *ShaderModuleWGSLDescriptor
}
ShaderModuleDescriptor mirrors cogentcore's subset (WGSL only).
type ShaderModuleWGSLDescriptor ¶
type ShaderModuleWGSLDescriptor struct {
Code string
}
ShaderModuleWGSLDescriptor carries WGSL source. Field name matches cogentcore.
type ShaderStage ¶
type ShaderStage uint64
ShaderStage is a bitset of WGPUShaderStage flags.
const ( ShaderStageNone ShaderStage = 0x0000000000000000 ShaderStageCompute ShaderStage = 0x0000000000000004 )
type SubmissionIndex ¶
type SubmissionIndex uint64
SubmissionIndex identifies a queue submission (for fenced Poll).
type SupportedLimits ¶
type SupportedLimits struct{ Limits Limits }
SupportedLimits / RequiredLimits wrap Limits, matching cogentcore's shape.
type WrappedSubmissionIndex ¶
type WrappedSubmissionIndex struct {
Queue *Queue
SubmissionIndex SubmissionIndex
}
WrappedSubmissionIndex identifies a specific queue submission to wait on in Poll. Matches cogentcore's shape; the Queue field is retained for source compatibility.
Source Files
¶
Directories
¶
| Path | Synopsis |
|---|---|
|
cmd
|
|
|
chainbench
command
Command chainbench is a self-contained synthetic benchmark for isolating the per-BARRIER and per-DISPATCH cost of a serially-dependent compute-dispatch chain on wgpu-native — the shape goinfer's ~535-dispatch decode chain takes.
|
Command chainbench is a self-contained synthetic benchmark for isolating the per-BARRIER and per-DISPATCH cost of a serially-dependent compute-dispatch chain on wgpu-native — the shape goinfer's ~535-dispatch decode chain takes. |
|
chainprobe
command
Command chainprobe is a SELF-CONTAINED, version-portable variant of the chainbench experiment used for the wgpu-native version bisect (STEP 2) and as the minimal standalone repro for an upstream gfx-rs/wgpu issue (STEP 4).
|
Command chainprobe is a SELF-CONTAINED, version-portable variant of the chainbench experiment used for the wgpu-native version bisect (STEP 2) and as the minimal standalone repro for an upstream gfx-rs/wgpu issue (STEP 4). |
|
dot4probe
command
Command dot4probe is the Phase-2 go/no-go: it brings up a wgpu-native v29 device through this binding, validates the struct ABI with a correctness check, and measures dot4I8Packed throughput against a scalar polyfill to detect whether the hardware DP4A path engages.
|
Command dot4probe is the Phase-2 go/no-go: it brings up a wgpu-native v29 device through this binding, validates the struct ABI with a correctness check, and measures dot4I8Packed throughput against a scalar polyfill to detect whether the hardware DP4A path engages. |
|
nagaprobe
command
Command nagaprobe is the decisive naga-codegen A/B (STEP "follow-up 3"): does v29's naga generate slower SPIR-V than v22-era naga for goinfer's real glue kernels? It isolates the COMPILER from the runtime by running two precompiled SPIR-V blobs (produced offline by naga-cli 22.0.0 and 29.0.0) on the SAME v29 wgpu-native runtime via SpirvShaderPassthrough (wgpuDeviceCreateShaderModuleSpirV) — the runtime's own naga never runs, so the driver receives exactly the bytes each naga version emitted.
|
Command nagaprobe is the decisive naga-codegen A/B (STEP "follow-up 3"): does v29's naga generate slower SPIR-V than v22-era naga for goinfer's real glue kernels? It isolates the COMPILER from the runtime by running two precompiled SPIR-V blobs (produced offline by naga-cli 22.0.0 and 29.0.0) on the SAME v29 wgpu-native runtime via SpirvShaderPassthrough (wgpuDeviceCreateShaderModuleSpirV) — the runtime's own naga never runs, so the driver receives exactly the bytes each naga version emitted. |