Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

StructTypeNode: Fix inclusion when added to the layout. #30439

Merged
merged 1 commit into from
Feb 1, 2025
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
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