Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 19 additions & 0 deletions src/nodes/code/FunctionCallNode.js
Original file line number Diff line number Diff line change
Expand Up @@ -69,12 +69,31 @@ class FunctionCallNode extends TempNode {

}

/**
* Returns the type of this function call node.
*
* @param {NodeBuilder} builder - The current node builder.
* @returns {string} The type of this node.
*/
getNodeType( builder ) {

return this.functionNode.getNodeType( builder );

}

/**
* Returns the function node of this function call node.
*
* @param {NodeBuilder} builder - The current node builder.
* @param {string} [name] - The name of the member.
* @returns {string} The type of the member.
*/
getMemberType( builder, name ) {

return this.functionNode.getMemberType( builder, name );

}

generate( builder ) {

const params = [];
Expand Down
23 changes: 23 additions & 0 deletions src/nodes/code/FunctionNode.js
Original file line number Diff line number Diff line change
Expand Up @@ -48,12 +48,35 @@ class FunctionNode extends CodeNode {

}

/**
* Returns the type of this function node.
*
* @param {NodeBuilder} builder - The current node builder.
* @return {string} The type.
*/
getNodeType( builder ) {

return this.getNodeFunction( builder ).type;

}

/**
* Returns the type of a member of this function node.
*
* @param {NodeBuilder} builder - The current node builder.
* @param {string} name - The name of the member.
* @return {string} The type of the member.
*/
getMemberType( builder, name ) {

const type = this.getNodeType( builder );

const structType = builder.getStructTypeNode( type );

return structType.getMemberType( builder, name );

}

/**
* Returns the inputs of this function node.
*
Expand Down
22 changes: 22 additions & 0 deletions src/nodes/core/NodeBuilder.js
Original file line number Diff line number Diff line change
Expand Up @@ -259,6 +259,13 @@ class NodeBuilder {
*/
this.structs = { vertex: [], fragment: [], compute: [], index: 0 };

/**
* This dictionary holds the types of the builder.
*
* @type {Object}
*/
this.types = { vertex: [], fragment: [], compute: [], index: 0 };

/**
* This dictionary holds the bindings for each shader stage.
*
Expand Down Expand Up @@ -1680,6 +1687,20 @@ class NodeBuilder {

}

/**
* Returns an instance of {@link StructType} for the given struct name and shader stage
* or null if not found.
*
* @param {string} name - The name of the struct.
* @param {('vertex'|'fragment'|'compute'|'any')} [shaderStage=this.shaderStage] - The shader stage.
* @return {?StructType} The struct type or null if not found.
*/
getStructTypeNode( name, shaderStage = this.shaderStage ) {

return this.types[ shaderStage ][ name ] || null;

}

/**
* Returns an instance of {@link StructType} for the given output struct node.
*
Expand All @@ -1704,6 +1725,7 @@ class NodeBuilder {
structType = new StructType( name, membersLayout );

this.structs[ shaderStage ].push( structType );
this.types[ shaderStage ][ name ] = node;

nodeData.structType = structType;

Expand Down
Loading