Rendering
DriftTexture
171 symbols, imported from @driftengine/texture.
Explained in DriftTexture.
Interfaces
ChannelSpecDecodeGraphDecodeResourcesGraphBuilderGraphEvaluatorGraphNodeGraphTensorGraphValueInstanceTileInfo- What
tilesForViewneeds besides the view. LatentImageLatentLevel- One level of a latent's chain. Components are the image's own.
LerpWeightsMaterialArray- Materials as slices of a few texture arrays, which is what WebGPU can bind.
MaterialTileGrid- One latent's tiles, level by level, by content.
NetworkGraphNetworkShapeOperatorOverlayOverlayJournalOverlayOptionsOverlayTilePageCachePageCacheOptionsPredictorPrefetchQueue- What to fetch next, ordered by how soon it will be needed.
ResidencyTableSimulationHandle- What prediction needs from a simulation.
StoredGraph- A graph as a file stores it: its tensors in either precision, half as the bits a device uploads.
@driftengine/drft'sDrftGraphis one, structurally, which is how the two packages meet without either importing the other. StreamerStreamerOptionsTileIndexTileSource- Where a tile's bytes come from. Resolving
nullmeans the source does not have it. WeightsWeightSource- Where a definition's weights come from: a checkpoint being converted, or a converted file.
Functions
acquirePage- The slot holding this tile's page, acquiring one if it is not held.
-1where none can be given. activationBound- The largest magnitude any product, partial sum or output of the network can reach over the given input box.
addBias- Add
bias[cols]to every one ofrowsrows ofx, in place. addDecodeNodeapplyOverlayJournal- Apply every entry up to and including
upToFrame, onto whatever the overlay already holds. arrayDescriptor- What a bind group needs to know: how many layers and how large each is.
assignLayer- Give this material a layer. Returns it, or -1 when the array is full.
attentionout[batch][queries][channels]fromqof that shape andkandvof[batch][keys][channels].scratchholds at leastqueries × keysvalues and is overwritten.beginCacheFrame- Say a new frame has begun, so everything acquired from here is protected from eviction.
clearMissingclearOverlay- Throw away every written tile. The overlay keeps its shape and holds nothing.
compositeOverlay- Put the overlay over the base, channel by channel, into
out. conv2dout[cout][oh][ow]frominput[cin][h][w], withoh = ⌊(h + 2·padding − kh)/stride⌋ + 1and likewiseow.biasmay be null.convTranspose2dout[cout][oh][ow]frominput[cin][h][w], withoh = (h − 1)·stride − 2·padding + kh: each input pixel spread over the kernel at its strided place, which is how a decoder head upsamples.createDecodeGraphcreateDecodeRegisters- A registers array of the right size, for a caller that holds one across calls.
createGraphEvaluator- Validate, size every value once, and return something that evaluates without allocating.
createMaterialArraycreateOverlaycreateOverlayJournalcreatePageCachecreatePrefetchQueuecreateResidencyTablecreateStreamercreateTileIndexdecodeCpu- Run the graph at one texture coordinate and one time, writing four components into
out. decodeDecodeGraphdecodeModedecodeOverlayJournal- Read a journal back. Null where the bytes are not one.
emptyLike- An overlay with the same shape as
likeand nothing written. What a replay starts from. encodeDecodeGraphcount,result,addressMode, then the nodes.encodeOverlayJournalenqueueensurePageDecoded- Decode a held page if the mode says the cache owns that, and it has not been done.
erf- The error function, to double precision.
evalNetwork- Evaluate the network, writing
shape.outputsvalues intoout. evalNetworkHalf- Evaluate the network as a device with
enable f16would, writingshape.outputsvalues intoout. evictflipbookFrame- Which frame of a flipbook this time lands on. Never negative, never past the end.
forgetMissing- Stop calling a tile missing, so the next pump asks for it again.
fromHalfBits- The value sixteen bits hold.
gelux·Φ(x), the exact GELU, fromxintoout.graphForDevice- A graph as
@driftengine/core's runner takes it: its tensors listed by name, and every value's shape as inferred here — nothing evaluated and nothing sized, where asking an evaluator for its shapes would allocate every intermediate value first. Structural, because core does not import this package; the shapes are this module's, so there is one copy of every operator's rule. graphFromStored- A stored graph as one the runtime runs, half-precision tensors decoded to single; validated, and refused naming what is wrong — an operator the runtime lacks is a fact about the model, and this is when a caller learns it.
graphFromWeightsgraphRegisterCount- The highest register the graph writes, plus one.
graphShapes- Every value's shape — inputs, tensors and intermediates — refused, with the reason, if invalid.
halfPrecisionErrorBound- How far the half-precision evaluation of this network, at this input, can sit from the single-precision one.
halfWeights- A whole weight array as half-precision bits, each weight rounded on its own.
hashTile- FNV-1a over 64 bits, carried as two 32-bit halves because JavaScript has no 64-bit integer.
internTile- Give this tile a slot, reusing the one its content already has.
isColour- Whether this channel carries colour, and therefore whether a transfer curve applies to it.
journalLengthlatentLerpWeights- The two keys surrounding this time, and how far between them it sits.
latentTileGrid- Cut a latent and its chain into content-addressed tiles.
layerNorm- Each row normalised to zero mean and unit variance, then scaled by
gammaand shifted bybeta. layerOfleastRecentlyUsed- The least recently used resident tiles, oldest first, excluding anything touched since
since. linearToSrgbmarkRequestedmarkResidentmatmulout[m×n] = a[m×k] · b, wherebisk×n, orn×kread as its transpose whentransposeB. The offsets are where each matrix starts in its array, which is how one head of many is taken.maxPool2dout[channels][oh][ow], each the largest of itskernel-square window atstride, withoh = ⌊(h − kernel)/stride⌋ + 1: no padding, and a ragged last row or column dropped, as PyTorch'smax_pool2ddoes withoutceil_mode.needsVarianceMips- Whether mipping this channel must preserve the normal distribution. See
mipNdf.ts. networkWeightCount- How many weights and biases a shape needs, laid out layer by layer.
nodeAnodeBnodeOpnodeOutnormaliseSample- Write one raw channel value into its component of
out, with its convention already applied. occupiedPages- How many pages are held. What a profiler panel shows beside the resident tile count.
overlayTileCount- How many tiles hold a written texel. What a memory readout shows.
overlayTiles- The distinct content hashes of the written tiles, into
out. Returns how many. pageDecodedpageSlotpatchEmbed- A patch embedding: a convolution with stride and kernel both
patch, written token-major —out[tokens][dim], tokens row by row — which is the order a transformer reads them in. predictViews- Fill
outwith one view matrix per predicted frame, and leave the simulation exactly as found. progressiveOrder- Fill
outwith the order to sendtileCounttiles in. Returns how many were written. pumpStreamer- Ask for the first
counttiles ofbatchthat are worth asking for. Returns how many were sent. queueSizerecordOverlayWrite- Record a write. Stored as
f32, which is what makes the encoding round-trip exactly. reduceNormalMip- Reduce a block of normals to one, writing both the direction and the roughness it implies.
releasePage- Give a page back. Its slot is free for the next acquisition, and its bytes are not kept.
residentCountresizeout[channels][outH][outW]resized frominput[channels][inH][inW].step, without aligned corners, is the source pixels a destination pixel covers, vertically and then horizontally, where it is not the ratio of the sizes.rewindOverlay- Put the overlay back to how it was at
upToFrame: clear, then replay. roundHalf- The nearest half-precision value, as a number.
runPrediction- Advance the simulation, ask the predictor what each predicted view needs, and put it back.
sampleOverlay- Read every channel at a coordinate into
out. False where nothing has been written there. semanticAt- The semantic an index names, or null where a file names one from a later version.
semanticIndex- Where a semantic sits in that order, or −1 for one this build does not know.
setDecodeMode- Change where the decode happens, invalidating every page that was decoded under the old rule.
slotForsoftmax- Each row of
xto a distribution, stably: the row's largest value is subtracted before the exponential, so logits near a thousand give their logistic rather thanInfinity / Infinity. srgbToLinear- The exact sRGB transfer function, piecewise, not the 2.2 power approximation.
streamerInFlighttakeBatch- Take the next batch, soonest first, within a byte budget.
takeEvicted- Drain the hashes whose pages have been taken, into
out. Returns how many. tilesForView- Fill
outwith the tiles this view would sample, most important first, at mostbudgetof them. Returns how many. tileSlotCounttileStatetoHalfBits- The sixteen bits a value rounds to, as an unsigned integer.
toksvigRoughness- How much roughness a shortened average normal implies.
touchTile- Say this tile is in use now, so eviction will not take it.
truncateJournalFrom- Forget every entry from
frameonward. What a rollback owes the journal. usableAt- What level this many received bytes supports.
validateDecodeGraph- Whether this graph is one an interpreter can run.
validateGraph- Null when the graph can run; otherwise the reason, naming what it is about.
writeOverlay- Write
valueinto one channel of every texel withinradiusof(u, v). writtenMaskAt- Which channels have been written at a coordinate, as a bit per channel. Zero for none.
Types
Architecture- A definition: it reads its weights, adds its nodes, and says what goes in and comes out.
AttributesAttributeValue- What every operator table shares: the shape of an operator, and the few helpers they all read their attributes and shapes with.
ChannelSemantic- What a channel is, declared rather than conventional.
DecodeMode- Where the decode happens. See the header for which risk the second one is the answer to.
DecodeOpPageDecode- How a page's bytes are produced. Supplied by the caller: a cache cannot know a format.
Constants
ADDRESS_CLAMPADDRESS_MODE- Where a coordinate lands, and what happens outside the unit square.
ADDRESS_MODE_COUNT- How many address modes there are. A graph asking for this many or more is refused.
ADDRESS_WRAPCHANNEL_SEMANTICS- Every semantic, in the order a file stores them by.
CONSTANT_PREFIX- What a constant's name begins with: a table of the shapes, never a weight.
DECODE_OP- A texture's decoder, as data.
HALF_MAX- The largest finite half-precision value.
JOURNAL_ENTRY_BYTES- Bytes an entry takes on the wire: two
u32and fourf32. JOURNAL_MAGIC"DOVJ", little-endian, as every other record in this package spells its magic.JOURNAL_VERSIONLEVEL_MARGIN- How close to a level boundary, in levels, an estimate names the finer level as well.
MAX_REGISTERS- Registers the interpreter has, each a four-component vector.
NODE_STRIDE- Words per node: op, a, b, out.
OPERATORSOVERLAY_CHANNELS- How many channels a texel carries. One bit each in the written mask, so this cannot exceed 8.
REMAP_SEMANTICS- The order
REMAP_CHANNELpacks a semantic in, which isCHANNEL_SEMANTICSand not a copy of it. TILE_ABSENT- What is here, what is on its way, and what is not.
TILE_REQUESTEDTILE_RESIDENT