Loading...
Searching...
No Matches
Computation Definition Language

Plugin computations are defined using the domain-specific Computation Definition Language. More...

+ Collaboration diagram for Computation Definition Language:

Modules

 Computation Registrations
 Computation registrations initiate the process of defining computations.
 
 Input Registrations
 An input registration is a specification of how an input value will be provided to a computation callback at evaluation time.
 

Macros

#define EXEC_REGISTER_COMPUTATIONS_FOR_SCHEMA(SchemaType)
 Initiates registration of exec computations for the schema SchemaType.
 

Detailed Description

Plugin computations are defined using the domain-specific Computation Definition Language.

Each plugin computation is registered for a particular schema, either typed or applied. When a computation is requested on a provider prim or attribute, if the requested computation name is not a builtin computation name, exec compilation considers the computations registered for the typed schema for the prim, the ancestor schema types, and API schemas applied to the prim, and looks for a computation of the requested name.

To define computations for a schema, the plugin code must invoke the EXEC_REGISTER_COMPUTATIONS_FOR_SCHEMA() macro. The macro invocation is immediately followed by a block of code that uses computation registrations that registers the associated plugin computations. Most of the language is dedicated to expressing input registrations, which provide exec compilation with the information it needs to compile the input connections that supply input values when the network is evaluated.

Example

The following cpp file could be used in a plugin library to define the computeMyAttributeValue prim computation for the MySchemaType schema:

{
// Register a prim computation that returns the computed value of an
// attribute.
self.PrimComputation(_tokens->computeMyAttributeValue)
.Callback<double>(+[](const VdfContext &ctx) {
ctx->SetOutput(ctx.GetInputValue<double>(_tokens->myAttribute));
})
.Inputs(
AttributeValue<double>(_tokens->myAttribute).Required());
}
A context is the parameter bundle passed to callbacks of computations.
Definition: context.h:40
#define EXEC_REGISTER_COMPUTATIONS_FOR_SCHEMA(SchemaType)
Initiates registration of exec computations for the schema SchemaType.

The library's plugInfo.json must contain the following data in the Info block in order for the execution system to load the library when computations are requested on a prim that uses MySchemaType:

"Info": {
"Exec": {
"Schemas": {
"MyComputationalSchema1": {
"allowsPluginComputations": true
},
"MyComputationalSchema2": {
},
"MyNonComputationalSchema": {
"allowsPluginComputations": false
}
}
}
}

The boolean allowsPluginComputations is used to declare schemas for which computations cannot be registered. If allowsPluginComputations isn't present in the plugInfo, its value defaults to true. I.e., schemas that appear in the Exec/Schemas plugInfo allow plugin computations by default.

Macro Definition Documentation

◆ EXEC_REGISTER_COMPUTATIONS_FOR_SCHEMA

#define EXEC_REGISTER_COMPUTATIONS_FOR_SCHEMA (   SchemaType)

Initiates registration of exec computations for the schema SchemaType.

Parameters
SchemaTypeThe schema type for which exec computations can be registered in the code block that follows an invocation of this macro.

Note:
For the full reference on the domain-specific language that is used to register exec computations refer to the Computation Definition Language reference page.

Definition at line 42 of file registerSchema.h.