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
22 changes: 22 additions & 0 deletions src/nodes/gpgpu/ComputeNode.js
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,14 @@ class ComputeNode extends Node {
*/
this.version = 1;

/**
* The name or label of the uniform.
*
* @type {String}
* @default ''
*/
this.name = '';

/**
* The `updateBeforeType` is set to `NodeUpdateType.OBJECT` since {@link ComputeNode#updateBefore}
* is executed once per object by default.
Expand Down Expand Up @@ -102,6 +110,20 @@ class ComputeNode extends Node {

}

/**
* Sets the {@link ComputeNode#name} property.
*
* @param {String} name - The name of the uniform.
* @return {ComputeNode} A reference to this node.
*/
label( name ) {

this.name = name;

return this;

}

/**
* TODO
*/
Expand Down
8 changes: 5 additions & 3 deletions src/renderers/common/Pipelines.js
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ class Pipelines extends DataMap {

if ( previousPipeline && previousPipeline.computeProgram.usedTimes === 0 ) this._releaseProgram( previousPipeline.computeProgram );

stageCompute = new ProgrammableStage( nodeBuilderState.computeShader, 'compute', nodeBuilderState.transforms, nodeBuilderState.nodeAttributes );
stageCompute = new ProgrammableStage( nodeBuilderState.computeShader, 'compute', computeNode.name, nodeBuilderState.transforms, nodeBuilderState.nodeAttributes );
this.programs.compute.set( nodeBuilderState.computeShader, stageCompute );

backend.createProgram( stageCompute );
Expand Down Expand Up @@ -111,6 +111,8 @@ class Pipelines extends DataMap {

const nodeBuilderState = renderObject.getNodeBuilderState();

const name = renderObject.material ? renderObject.material.name : '';

// programmable stages

let stageVertex = this.programs.vertex.get( nodeBuilderState.vertexShader );
Expand All @@ -119,7 +121,7 @@ class Pipelines extends DataMap {

if ( previousPipeline && previousPipeline.vertexProgram.usedTimes === 0 ) this._releaseProgram( previousPipeline.vertexProgram );

stageVertex = new ProgrammableStage( nodeBuilderState.vertexShader, 'vertex' );
stageVertex = new ProgrammableStage( nodeBuilderState.vertexShader, 'vertex', name );
this.programs.vertex.set( nodeBuilderState.vertexShader, stageVertex );

backend.createProgram( stageVertex );
Expand All @@ -132,7 +134,7 @@ class Pipelines extends DataMap {

if ( previousPipeline && previousPipeline.fragmentProgram.usedTimes === 0 ) this._releaseProgram( previousPipeline.fragmentProgram );

stageFragment = new ProgrammableStage( nodeBuilderState.fragmentShader, 'fragment' );
stageFragment = new ProgrammableStage( nodeBuilderState.fragmentShader, 'fragment', name );
this.programs.fragment.set( nodeBuilderState.fragmentShader, stageFragment );

backend.createProgram( stageFragment );
Expand Down
11 changes: 10 additions & 1 deletion src/renderers/common/ProgrammableStage.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,10 +14,11 @@ class ProgrammableStage {
*
* @param {String} code - The shader code.
* @param {('vertex'|'fragment'|'compute')} stage - The type of stage.
* @param {String} name - The name of the shader.
* @param {Array<Object>?} [transforms=null] - The transforms (only relevant for compute stages with WebGL 2 which uses Transform Feedback).
* @param {Array<Object>?} [attributes=null] - The attributes (only relevant for compute stages with WebGL 2 which uses Transform Feedback).
*/
constructor( code, stage, transforms = null, attributes = null ) {
constructor( code, stage, name, transforms = null, attributes = null ) {

/**
* The id of the programmable stage.
Expand All @@ -40,6 +41,14 @@ class ProgrammableStage {
*/
this.stage = stage;

/**
* The name of the stage.
* This is used for debugging purposes.
*
* @type {String}
*/
this.name = name;

/**
* The transforms (only relevant for compute stages with WebGL 2 which uses Transform Feedback).
*
Expand Down
2 changes: 1 addition & 1 deletion src/renderers/common/Renderer.js
Original file line number Diff line number Diff line change
Expand Up @@ -414,7 +414,7 @@ class Renderer {
* @type {QuadMesh}
*/
this._quad = new QuadMesh( new NodeMaterial() );
this._quad.material.type = 'Renderer_output';
this._quad.material.name = 'Renderer_output';

/**
* A reference to the current render context.
Expand Down
2 changes: 1 addition & 1 deletion src/renderers/webgpu/WebGPUBackend.js
Original file line number Diff line number Diff line change
Expand Up @@ -1288,7 +1288,7 @@ class WebGPUBackend extends Backend {
const programGPU = this.get( program );

programGPU.module = {
module: this.device.createShaderModule( { code: program.code, label: program.stage } ),
module: this.device.createShaderModule( { code: program.code, label: program.stage + ( program.name !== '' ? `_${ program.name }` : '' ) } ),
entryPoint: 'main'
};

Expand Down
Loading