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
14 changes: 9 additions & 5 deletions build/three.cjs
Original file line number Diff line number Diff line change
Expand Up @@ -75812,6 +75812,10 @@ class WebGLRenderer {
let _isContextLost = false;
let _nodesHandler = null;

let _scratchFramebuffer = null;
let _srcFramebuffer = null;
let _dstFramebuffer = null;

// internal state cache

this._outputColorSpace = SRGBColorSpace;
Expand Down Expand Up @@ -75955,6 +75959,10 @@ class WebGLRenderer {

}

_scratchFramebuffer = _gl.createFramebuffer();
_srcFramebuffer = _gl.createFramebuffer();
_dstFramebuffer = _gl.createFramebuffer();

info = new WebGLInfo( _gl );
properties = new WebGLProperties();
textures = new WebGLTextures( _gl, extensions, state, properties, capabilities, utils, info );
Expand Down Expand Up @@ -78387,8 +78395,6 @@ class WebGLRenderer {

};

const _scratchFrameBuffer = _gl.createFramebuffer();

/**
* Sets the active rendertarget.
*
Expand Down Expand Up @@ -78521,7 +78527,7 @@ class WebGLRenderer {
// being bound that are different sizes.
if ( activeMipmapLevel !== 0 ) {

framebuffer = _scratchFrameBuffer;
framebuffer = _scratchFramebuffer;

}

Expand Down Expand Up @@ -78764,8 +78770,6 @@ class WebGLRenderer {

};

const _srcFramebuffer = _gl.createFramebuffer();
const _dstFramebuffer = _gl.createFramebuffer();

/**
* Copies data of the given source texture into a destination texture.
Expand Down
14 changes: 9 additions & 5 deletions build/three.module.js
Original file line number Diff line number Diff line change
Expand Up @@ -16238,6 +16238,10 @@ class WebGLRenderer {
let _isContextLost = false;
let _nodesHandler = null;

let _scratchFramebuffer = null;
let _srcFramebuffer = null;
let _dstFramebuffer = null;

// internal state cache

this._outputColorSpace = SRGBColorSpace;
Expand Down Expand Up @@ -16381,6 +16385,10 @@ class WebGLRenderer {

}

_scratchFramebuffer = _gl.createFramebuffer();
_srcFramebuffer = _gl.createFramebuffer();
_dstFramebuffer = _gl.createFramebuffer();

info = new WebGLInfo( _gl );
properties = new WebGLProperties();
textures = new WebGLTextures( _gl, extensions, state, properties, capabilities, utils, info );
Expand Down Expand Up @@ -18813,8 +18821,6 @@ class WebGLRenderer {

};

const _scratchFrameBuffer = _gl.createFramebuffer();

/**
* Sets the active rendertarget.
*
Expand Down Expand Up @@ -18947,7 +18953,7 @@ class WebGLRenderer {
// being bound that are different sizes.
if ( activeMipmapLevel !== 0 ) {

framebuffer = _scratchFrameBuffer;
framebuffer = _scratchFramebuffer;

}

Expand Down Expand Up @@ -19190,8 +19196,6 @@ class WebGLRenderer {

};

const _srcFramebuffer = _gl.createFramebuffer();
const _dstFramebuffer = _gl.createFramebuffer();

/**
* Copies data of the given source texture into a destination texture.
Expand Down
2 changes: 1 addition & 1 deletion build/three.module.min.js

Large diffs are not rendered by default.

105 changes: 80 additions & 25 deletions build/three.webgpu.js
Original file line number Diff line number Diff line change
Expand Up @@ -3871,8 +3871,6 @@ Object.defineProperties( Node.prototype, proto );

// --- FINISH ---

const nodeBuilderFunctionsCacheMap = new WeakMap();

const ShaderNodeObject = function ( obj, altType = null ) {

const type = getValueType( obj );
Expand Down Expand Up @@ -4086,35 +4084,59 @@ class ShaderCallNodeInternal extends Node {

if ( shaderNode.layout ) {

const backend = builder.renderer.backend;
// build inputs first

let functionNodesCacheMap = nodeBuilderFunctionsCacheMap.get( backend );
if ( rawInputs ) {

if ( functionNodesCacheMap === undefined ) {
// use layout inputs to ensure that no extra parameters are built

functionNodesCacheMap = new WeakMap();
const inputs = shaderNode.layout.inputs;

nodeBuilderFunctionsCacheMap.set( backend, functionNodesCacheMap );
if ( isArrayAsParameter( rawInputs ) ) {

}
const rawArrayParameters = rawInputs;

for ( let i = 0; i < inputs.length; i ++ ) {

const rawParameter = rawArrayParameters[ i ];

if ( rawParameter && rawParameter.isNode ) {

rawParameter.build( builder );

}

}

} else {

let functionNode = functionNodesCacheMap.get( shaderNode );
const rawObjectParameters = rawInputs[ 0 ];

if ( functionNode === undefined ) {
for ( const param of inputs ) {

functionNode = nodeObject( builder.buildFunctionNode( shaderNode ) );
const rawParameter = rawObjectParameters[ param.name ];

functionNodesCacheMap.set( shaderNode, functionNode );
if ( rawParameter && rawParameter.isNode ) {

rawParameter.build( builder );

}

}

}

}

const functionNode = builder.buildFunctionNode( shaderNode );

builder.addInclude( functionNode );

//

const inputs = rawInputs ? getLayoutParameters( rawInputs ) : null;

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

} else {

Expand Down Expand Up @@ -4261,15 +4283,19 @@ class ShaderCallNodeInternal extends Node {

}

function isArrayAsParameter( params ) {

return params[ 0 ] && ( params[ 0 ].isNode || Object.getPrototypeOf( params[ 0 ] ) !== Object.prototype );

}

function getLayoutParameters( params ) {

let output;

nodeObjects( params );

const isArrayAsParameter = params[ 0 ] && ( params[ 0 ].isNode || Object.getPrototypeOf( params[ 0 ] ) !== Object.prototype );

if ( isArrayAsParameter ) {
if ( isArrayAsParameter( params ) ) {

output = [ ...params ];

Expand Down Expand Up @@ -32416,13 +32442,20 @@ class Bindings extends DataMap {
const bindings = this.nodes.getForCompute( computeNode ).bindings;
const computeNodeData = this.get( computeNode );

if ( computeNodeData.initialized !== true ) {
if ( computeNodeData.initialized !== true || computeNodeData.bindings !== bindings ) {

// bind groups are created once per object
// bind groups are created once per compute node version

if ( computeNodeData.bindings !== undefined ) {

this._destroyBindings( computeNodeData.bindings );

}

this._createBindings( bindings );

computeNodeData.initialized = true;
computeNodeData.bindings = bindings;

}

Expand Down Expand Up @@ -32459,7 +32492,8 @@ class Bindings extends DataMap {
*/
deleteForCompute( computeNode ) {

const bindings = this.nodes.getForCompute( computeNode ).bindings;
const computeNodeData = this.get( computeNode );
const bindings = computeNodeData.bindings || this.nodes.getForCompute( computeNode ).bindings;

this._destroyBindings( bindings );

Expand Down Expand Up @@ -49870,6 +49904,7 @@ class Matrix4NodeUniform extends Matrix4Uniform {
let _id$5 = 0;

const _bindingGroupsCache = new WeakMap();
const _functionNodeCache = new WeakMap();

const sharedNodeData = new WeakMap();

Expand Down Expand Up @@ -52213,15 +52248,34 @@ class NodeBuilder {
*/
buildFunctionNode( shaderNode ) {

const fn = new FunctionNode();
const backend = this.renderer.backend;

let cache = _functionNodeCache.get( backend );

const previous = this.currentFunctionNode;
if ( cache === undefined ) {

this.currentFunctionNode = fn;
cache = new WeakMap();
_functionNodeCache.set( backend, cache );

fn.code = this.buildFunctionCode( shaderNode );
}

this.currentFunctionNode = previous;
let fn = cache.get( shaderNode );

if ( fn === undefined ) {

fn = new FunctionNode();

const previous = this.currentFunctionNode;

this.currentFunctionNode = fn;

fn.code = this.buildFunctionCode( shaderNode );

this.currentFunctionNode = previous;

cache.set( shaderNode, fn );

}

return fn;

Expand Down Expand Up @@ -54874,14 +54928,15 @@ class NodeManager extends DataMap {

let nodeBuilderState = computeData.nodeBuilderState;

if ( nodeBuilderState === undefined ) {
if ( nodeBuilderState === undefined || computeData.version !== computeNode.version ) {

const nodeBuilder = this.backend.createNodeBuilder( computeNode, this.renderer );
nodeBuilder.build();

nodeBuilderState = this._createNodeBuilderState( nodeBuilder );

computeData.nodeBuilderState = nodeBuilderState;
computeData.version = computeNode.version;

}

Expand Down
2 changes: 1 addition & 1 deletion build/three.webgpu.min.js

Large diffs are not rendered by default.

Loading
Loading