Skip to content

RenderInstruction

Overview

Represents an instruction to execute part of a RenderProgram based on an execution stack

@author Jonathan Olson <jonathan.olson@colorado.edu>

Class RenderInstruction

import { RenderInstruction } from 'scenerystack/alpenglow';

Instance Methods

execute( stack : RenderExecutionStack, context : RenderEvaluationContext, executor : RenderExecutor )

toString() : string

equals( other : RenderInstruction, areLocationsEqual : ( a: RenderInstructionLocation, b: RenderInstructionLocation ) => boolean ) : boolean

writeBinary( encoder : ByteEncoder, getOffset : ( location: RenderInstructionLocation ) => number )

getBinaryLength() : number

The number of dwords (u32s, 4 bytes) that this instruction takes up in the binary stream.

Static Methods

getInstructionLength( u32 : number ) : number

Returns the length (in dwords) of the binary form of an instruction, based on the initial u32 value in the instruction stream

instructionsToBinary( encoder : ByteEncoder, instructions : RenderInstruction[] )

Appends the binary form of the list of instructions to the encoder.

NOTE: The binary form will always have an exit instruction included at the end, so multiple instruction streams can be written into the same buffer (and noted with offsets).

binaryToInstructions( encoder : ByteEncoder, offset : number ) : RenderInstruction[]

Reads the binary from from the encoder (at a specific dword offset), and returns the list of instructions.

NOTE: No final "exit" is generated, since our executor for objects won't need it.

binaryToInstruction( encoder : ByteEncoder, offset : number, getLocation : ( offset: number ) => RenderInstructionLocation ) : RenderInstruction

Extracts a single instruction from the binary format at a given (32bit dword) offset.

instructionsEquals( a : RenderInstruction[], b : RenderInstruction[] ) : boolean

Returns whether two instruction lists are equivalent (allowing for equivalent location instructions).

It's possible to have one list where there are multiple location instructions in a row, so we'll need to inspect locations for these cases (since they can be equivalent to a single location instruction).

Static Properties

ExitCode

(readonly)

TODO: better code ordering, prevent duplicates length 1 NOTE: only instructions with length 1 should fit in the mask 0xf (4 bits) This condition will be detected

ReturnCode

(readonly)

StackBlendCode

(readonly)

LinearBlendCode

(readonly)

BlendComposeCode

(readonly)

OpaqueJumpCode

(readonly)

PremultiplyCode

(readonly)

UnpremultiplyCode

(readonly)

SRGBToLinearSRGBCode

(readonly)

LinearSRGBToSRGBCode

(readonly)

LinearDisplayP3ToLinearSRGBCode

(readonly)

LinearSRGBToLinearDisplayP3Code

(readonly)

OklabToLinearSRGBCode

(readonly)

LinearSRGBToOklabCode

(readonly)

NormalizeCode

(readonly)

NormalDebugCode

(readonly)

MultiplyScalarCode

(readonly)

Below here, the top bit MUST be set. This is to prevent the 0xf mask from matching these codes. The bottom 5 bits will be used for the length (FOR NOW, this could change), and the 2 bits after will be used to represent different instructions. NOTE: If we have 4 more 1-length instructions, we'll need to figure out a different encoding here NOTE: Actually, we really won't. For all of those 1-length ones, we can just PACK EVERYTHING IN THE HIGH BITS NOTE: top 2 bits set will note variadic instructions. So add... 0x80, 0xa0 as the two options length 2

PhongCode

(readonly)

length 3

PushCode

(readonly)

length 5

ComputeLinearBlendRatioCode

(readonly)

length 7

BarycentricBlendCode

(readonly)

length 8

BarycentricPerspectiveBlendCode

(readonly)

length 11

ComputeRadialBlendRatioCode

(readonly)

length 12

FilterCode

(readonly)

length 21

ComputeLinearGradientRatioCode

(readonly)

variable length(!)

ComputeRadialGradientRatioCode

(readonly)

ImageCode

(readonly)

CODE_NAME_CONSTANTS

(readonly)

Something we can pass in shader options.

Class RenderInstructionLocation

import { RenderInstructionLocation } from 'scenerystack/alpenglow';

Instance Methods

toString() : string

equals( other : RenderInstruction, areLocationsEqual : ( a: RenderInstructionLocation, b: RenderInstructionLocation ) => boolean ) : boolean

execute( stack : RenderExecutionStack, context : RenderEvaluationContext, executor : RenderExecutor )

writeBinary( encoder : ByteEncoder, getOffset : ( location: RenderInstructionLocation ) => number )

getBinaryLength() : number

Instance Properties

id

index

To be filled in before execution (if in JS)

Class RenderInstructionMultiplyScalar

import { RenderInstructionMultiplyScalar } from 'scenerystack/alpenglow';

Constructor

new RenderInstructionMultiplyScalar( factor : number )

Instance Methods

toString() : string

equals( other : RenderInstruction, areLocationsEqual : ( a: RenderInstructionLocation, b: RenderInstructionLocation ) => boolean ) : boolean

execute( stack : RenderExecutionStack, context : RenderEvaluationContext, executor : RenderExecutor )

writeBinary( encoder : ByteEncoder, getOffset : ( location: RenderInstructionLocation ) => number )

getBinaryLength() : number

Static Methods

fromBinary( encoder : ByteEncoder, offset : number, getLocation : ( offset: number ) => RenderInstructionLocation ) : RenderInstructionMultiplyScalar

Class RenderInstructionPush

import { RenderInstructionPush } from 'scenerystack/alpenglow';

Constructor

new RenderInstructionPush( vector : Vector4 )

Instance Methods

toString() : string

equals( other : RenderInstruction, areLocationsEqual : ( a: RenderInstructionLocation, b: RenderInstructionLocation ) => boolean ) : boolean

execute( stack : RenderExecutionStack, context : RenderEvaluationContext, executor : RenderExecutor )

writeBinary( encoder : ByteEncoder, getOffset : ( location: RenderInstructionLocation ) => number )

getBinaryLength() : number

Static Methods

fromBinary( encoder : ByteEncoder, offset : number, getLocation : ( offset: number ) => RenderInstructionLocation ) : RenderInstructionPush

Class RenderInstructionReturn

import { RenderInstructionReturn } from 'scenerystack/alpenglow';

Instance Methods

toString() : string

equals( other : RenderInstruction, areLocationsEqual : ( a: RenderInstructionLocation, b: RenderInstructionLocation ) => boolean ) : boolean

execute( stack : RenderExecutionStack, context : RenderEvaluationContext, executor : RenderExecutor )

writeBinary( encoder : ByteEncoder, getOffset : ( location: RenderInstructionLocation ) => number )

getBinaryLength() : number

Static Properties

INSTANCE : RenderInstructionReturn

(readonly)

Source Code

See the source for RenderInstruction.ts in the alpenglow repository.