Documentation
¶
Overview ¶
Package handletable maps opaque integer handles to Go objects.
HAL resources expose a NativeHandle() uintptr, and bind group entries carry those handles back into the backend (gputypes.BufferBinding.Buffer and so on). For Vulkan, Metal and the DX12 Texture that handle is a native object (a VkHandle, an Objective-C id, a COM pointer). Where a backend needs its own Go struct back instead (DX12 buffers, texture views and samplers, GLES texture views), the handle must not be the struct's address: converting a Go pointer to uintptr and back breaks rule 6 of the unsafe.Pointer rules (the uintptr does not keep the object alive and the GC may move or free it), and checkptr, which go test -race enables, reports it as a fatal error.
A Table hands out a fresh integer per object and resolves it through a map. The map holds the object alive until Remove, so a resource must Remove its handle when it is destroyed.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Table ¶
type Table[T any] struct { // contains filtered or unexported fields }
Table maps handles to *T. The zero value is an empty table ready to use. A Table must not be copied after first use.
func (*Table[T]) Add ¶
Add registers v and returns its handle. Handles are never 0 (0 means "no resource" in the HAL binding types) and increase monotonically, so a removed handle is not handed out again until the counter wraps.