Help us shape the future of Go! Take the 2026 Go Developer Survey

indirect

package
v0.34.7 Latest Latest
Warning

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

Go to latest
Published: Nov 3, 2026 License: MIT Imports: 2 Imported by: 0

Documentation

Overview

Package indirect provides overflow-safe arithmetic for indirect draw spans.

Index

Constants

View Source
const DispatchArgsSize = 12

DispatchArgsSize is the size of DispatchIndirect arguments: x, y, z as u32.

Variables

This section is empty.

Functions

func DelegatedValidationOffset

func DelegatedValidationOffset(bufferSize, offset, recordSize uint64, count uint32) uint64

DelegatedValidationOffset returns the last record offset for a span, or the buffer size when offset arithmetic overflows. Backends with single-record validation can use it to delegate one deterministic failing operation.

func RangeFits

func RangeFits(bufferSize, offset, recordSize uint64, count uint32) bool

RangeFits reports whether count consecutive records fit in a buffer.

func RecordOffset

func RecordOffset(offset, recordSize uint64, index uint32) (uint64, bool)

RecordOffset returns the byte offset of a record without uint64 wraparound.

Types

type BindGroupCache

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

BindGroupCache holds the validation bind groups of one arguments buffer, one per binding offset, created on first use. The bind groups live as long as the buffer: commands recorded with them may run until the buffer's last use completes, so they are destroyed with the buffer (Rust wgpu-core Buffer::indirect_validation_bind_groups, disposed when the buffer drops).

func (*BindGroupCache) Destroy

func (c *BindGroupCache) Destroy(device hal.Device)

Destroy destroys every bind group in the cache with device and empties it.

func (*BindGroupCache) Get

func (c *BindGroupCache) Get(key uint64, create func() (hal.BindGroup, error)) (hal.BindGroup, error)

Get returns the bind group for key, creating it with create on first use.

type DispatchSource

type DispatchSource struct {
	BindingOffset uint64 // byte offset of the binding, a multiple of the alignment
	BindingSize   uint64 // byte size of the binding, a multiple of 4
	Index         uint32 // u32 index of x inside the binding
}

DispatchSource says where the indirect dispatch validation shader reads the arguments of one DispatchIndirect: a storage binding of the arguments buffer at an offset aligned to minStorageBufferOffsetAlignment, and the u32 index of x inside that binding.

Rust wgpu-core (indirect_validation/dispatch.rs Dispatch::params) splits the offset the same way: the aligned part becomes the dynamic offset of the source binding and the remainder an immediate. Without immediates and dynamic offsets in every HAL, core binds the aligned offset statically and selects the remainder from a constant table, so Index is always below alignment/4.

func DispatchSourceFor

func DispatchSourceFor(offset, bufferSize uint64, alignment uint32) DispatchSource

DispatchSourceFor returns the source binding for arguments at offset in a buffer of bufferSize bytes. The caller has checked that offset is a multiple of 4 and that offset+DispatchArgsSize <= bufferSize; alignment is minStorageBufferOffsetAlignment (a power of two, at least 4).

Jump to

Keyboard shortcuts

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