Documentation
¶
Overview ¶
Package mslmap builds the naga MSL binding map for the Metal backend.
naga translates WGSL arrayLength() into arithmetic on an extra entry point argument named `_buffer_sizes`. naga gives that argument a [[buffer(N)]] attribute only if msl.Options.PerEntryPointMap[ep].SizesBuffer is set. If it is not set, Metal binds nothing to the argument and arrayLength() returns a wrong value. The backend must therefore supply the map.
The map must list every resource, not only the sizes buffer. When an entry point is present in PerEntryPointMap, naga uses its Resources field as is and does not number the other resources itself. A map with only SizesBuffer would therefore lose every normal binding. This package copies naga's own numbering rule, so the MSL for normal resources stays the same.
The package has no build tags and does not call Objective-C, so its tests run on any CI runner.
Reference: Rust wgpu-hal metal/device.rs:851-856 (sizes_buffer = counters.buffers) and metal/device.rs:138-145 (load_shader takes the layout).
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func Options ¶
Options returns MSL options that put naga's `_buffer_sizes` argument at buffer slot sizesSlot. It does this for every entry point in module, and it numbers all other resources the same way naga does.
sizesSlot is the number of buffer bindings that the pipeline layout declares. That is the first free slot, directly after the last declared buffer. Rust wgpu-hal picks the slot the same way, after it walks the pipeline layout.
func RuntimeArrayBindings ¶
func RuntimeArrayBindings(module *ir.Module) ([]ir.ResourceBinding, error)
RuntimeArrayBindings returns the bindings of the global variables whose type holds a runtime-sized array. The order is the IR declaration order.
naga builds one uint32 field per such global, in this same order. Each field must hold the byte size of the buffer that is bound to it.
Reference: naga v0.18.0 msl/internal/codegen/writer.go:786-797 (scanBufferSizeGlobals).
Types ¶
This section is empty.