Skip to content

Commit

Permalink
StructTypeNode: Fix inclusion when added to the layout.
Browse files Browse the repository at this point in the history
  • Loading branch information
sunag committed Feb 1, 2025
1 parent 8a475a6 commit 15ff09b
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 6 deletions.
18 changes: 17 additions & 1 deletion src/nodes/core/NodeBuilder.js
Original file line number Diff line number Diff line change
Expand Up @@ -1636,7 +1636,7 @@ class NodeBuilder {
*/
getStructTypeFromNode( node, membersLayout, name = null, shaderStage = this.shaderStage ) {

const nodeData = this.getDataFromNode( node, shaderStage );
const nodeData = this.getDataFromNode( node, shaderStage, this.globalCache );

let structType = nodeData.structType;

Expand Down Expand Up @@ -2047,6 +2047,22 @@ class NodeBuilder {

}

/**
* Includes a node in the current function node.
*
* @param {Node} node - The node to include.
* @returns {void}
*/
addInclude( node ) {

if ( this.currentFunctionNode !== null ) {

this.currentFunctionNode.includes.push( node );

}

}

/**
* Returns the native shader operator name for a given generic name.
* It is a similar type of method like {@link NodeBuilder#getMethod}.
Expand Down
6 changes: 6 additions & 0 deletions src/nodes/core/StructTypeNode.js
Original file line number Diff line number Diff line change
Expand Up @@ -116,6 +116,12 @@ class StructTypeNode extends Node {

}

setup( builder ) {

builder.addInclude( this );

}

generate( builder ) {

return this.getNodeType( builder );
Expand Down
6 changes: 1 addition & 5 deletions src/nodes/tsl/TSLCore.js
Original file line number Diff line number Diff line change
Expand Up @@ -307,11 +307,7 @@ class ShaderCallNodeInternal extends Node {

}

if ( builder.currentFunctionNode !== null ) {

builder.currentFunctionNode.includes.push( functionNode );

}
builder.addInclude( functionNode );

result = nodeObject( functionNode.call( inputNodes ) );

Expand Down

0 comments on commit 15ff09b

Please sign in to comment.